Skip to content

Latest commit

 

History

History
120 lines (91 loc) · 2.91 KB

README.md

File metadata and controls

120 lines (91 loc) · 2.91 KB

Example domain design - event sourcing - using rust cqrs

Small example project to implement a Plane aggregate using serverlesstechnology/cqrs.

This repository includes:

Developed thanks to:

event storming

Getting started

Prerequisites

  • developed with Rust 1.68
  • docker-compose

Run

# terminal 1
docker-compose up -d
cargo run

# terminal 2
./test/test_api_plane.sh

Expected terminal 1 output

crates/domain-plane/src/queries/logger.rs logs every Plane events

Format:

id: '{{Aggregate ID}}', sequence: {{Event number for the given aggregate}}

{{event as a JSON unless the event contains no data (e.g. "OnGround")}}

******************************************************
id: 'test-plane-27355', sequence: 1
{
  "Registered": {
    "registration_id": "test-plane-27355"
  }
}
******************************************************
id: 'test-plane-27355', sequence: 2
"OnGround"
******************************************************
id: 'test-plane-27355', sequence: 3
{
  "PositionedAt": {
    "latitude": 1.0,
    "longitude": 2.0,
    "altitude": 0
  }
}
******************************************************
id: 'test-plane-27355', sequence: 4
"TookOff"
******************************************************
id: 'test-plane-27355', sequence: 5
{
  "PositionedAt": {
    "latitude": 10.0,
    "longitude": 20.0,
    "altitude": 10
  }
}
******************************************************
id: 'test-plane-27355', sequence: 6
{
  "PositionedAt": {
    "latitude": 11.0,
    "longitude": 21.0,
    "altitude": 20
  }
}
******************************************************
id: 'test-plane-27355', sequence: 7
"Landed"

Expected terminal 2 output

The journey shows the plane's status and the current or last journey positions (history is cleared upon take off)

***************************
* Plane: test-plane-27355
***************************
Registering plane

Updating position

Prepare for take off!

Updating position

Journey
{"registration_id":"test-plane-27355","status":"InAir","positions":[{"latitude":10.0,"longitude":20.0,"altitude":10}]}

Updating position

Prepare for usual landing!

Journey
{"registration_id":"test-plane-27355","status":"OnGround","positions":[{"latitude":10.0,"longitude":20.0,"altitude":10},{"latitude":11.0,"longitude":21.0,"altitude":20}]}