Expand description
SQL database implementations for the Evento event sourcing library.
This crate provides SQL-based persistence for events and subscriber state, supporting SQLite, MySQL, and PostgreSQL through feature flags.
§Features
sqlite- Enables SQLite database supportmysql- Enables MySQL database supportpostgres- Enables PostgreSQL database support
All features are enabled by default. You can selectively enable only the databases you need:
[dependencies]
evento-sql = { version = "1.8", default-features = false, features = ["postgres"] }§Usage
The main type is Sql<DB>, a generic wrapper around a SQLx connection pool that
implements the Executor trait for event sourcing operations.
§Quick Start
ⓘ
use evento_sql::Sql;
use sqlx::sqlite::SqlitePoolOptions;
// Create a connection pool
let pool = SqlitePoolOptions::new()
.connect(":memory:")
.await?;
// Wrap it in the Sql executor
let executor: Sql<sqlx::Sqlite> = pool.into();
// Use with Evento for event sourcing operations§Type Aliases
Convenience type aliases are provided for each database:
Read-write pair types for CQRS patterns:
RwSqlite- Read/write SQLite executor pairRwMySql- Read/write MySQL executor pairRwPostgres- Read/write PostgreSQL executor pair
§Core Components
Sql- The main executor type wrapping a SQLx connection poolReader- Query builder for reading events with cursor-based paginationBind- Trait for cursor serialization in paginated queriesEvent,Subscriber,Snapshot- Sea-Query column identifiers
§Serialization
The sql_types module provides the Bitcode wrapper for compact
binary serialization of event data using the bitcode format.
Modules§
- sql_
types - SQL type wrappers for serialization.
Structs§
- Reader
- Query builder for reading events with cursor-based pagination.
- Sql
- SQL database executor for event sourcing operations.
- SqlEvent
Enums§
- Event
- Column identifiers for the
eventtable. - Snapshot
- Column identifiers for the
snapshottable. - Subscriber
- Column identifiers for the
subscribertable.
Traits§
- Bind
- Trait for binding cursor values in paginated queries.