When talking about microservices, inevitably paradigms like event-driven architecture and CQRS (Command-Response Segregation Principle) have to be considered.
Rust is an interesting language as it introduces a new paradigm different to languages such as Java/Go (garbage collection/.NET) and C/C++ (manual memory management). It is directly compiled to native code, but doesn’t require manual allocation of memory. It achieves this by having a strict mechanism called the borrow checker which checks object usage during compile time, flagging any potential memory issues.
Hence, I started a small open-source project with the aim of learning Rust. It provides a simple framework to handle protobuf-based messages which represent commands, command responses and events.
sequenceDiagram
participant Command Server
participant Command Service Client
participant Event Listener A
participant Event Listener B
Command Service Client->>Command Server: Create user 'Bob'
Note over Command Service Client,Command Server: Send CQRS command
activate Command Server
Command Server->>Command Service Client: Ok
deactivate Command Server
Note over Command Server,Command Service Client: CQRS command response (Ok/Not Ok)
par Command Server to Event Listener A
Command Server-->>Event Listener A: User 'Bob' created
and Command Server to Event Listener B
Command Server-->>Event Listener B: User 'Bob' created
end
Note over Command Server,Event Listener A: Produce a CQRS event
Rust Cargo Kafka Event Driven Architecture