Crate message_db

Source
Expand description

§Message DB

Rust Client for the Microservice Native Event Store and Message Store for Postgres

A fully-featured event store and message store implemented in PostgreSQL for Pub/Sub, Event Sourcing, Messaging, and Evented Microservices applications.

For more information, see the Message DB project page. https://github.com/message-db/message-db

§Example

use message_db::database::{MessageStore, WriteMessageOpts};
use serde_json::json;

// Connect to MessageDb
let message_store = MessageStore::connect("postgres://postgres:password@localhost:5432/postgres").await?;

// Get last stream message
let last_message = MessageStore::get_last_stream_message(&message_store, "account-123", None).await?;

// Write message
let last_message = MessageStore::write_message(
    &message_store,
    "account-123",
    "AccountOpened",
    &json!({ "initial_balance": 0 }),
    &WriteMessageOpts::default(),
).await?;

Modules§

databasedatabase
Message store database functionality.
message
A message is a data structure that represents either an instruction to be passed to a process (command), or a record of something that has happened (event) - typically in response to the processing of a command.
stream_name
Messages like events and commands are written to and read from streams. To write and read from streams, the subject stream is identified by its name.

Enums§

Error
Represents all the ways a method can fail.

Type Aliases§

Result
Type alias for Result<T, message_db::Error>