Skip to main content

Crate evento_sql

Crate evento_sql 

Source
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 support
  • mysql - Enables MySQL database support
  • postgres - 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 pair
  • RwMySql - Read/write MySQL executor pair
  • RwPostgres - Read/write PostgreSQL executor pair

§Core Components

  • Sql - The main executor type wrapping a SQLx connection pool
  • Reader - Query builder for reading events with cursor-based pagination
  • Bind - Trait for cursor serialization in paginated queries
  • Event, 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 event table.
Snapshot
Column identifiers for the snapshot table.
Subscriber
Column identifiers for the subscriber table.

Traits§

Bind
Trait for binding cursor values in paginated queries.

Type Aliases§

MySql
Type alias for MySQL executor.
Postgres
Type alias for PostgreSQL executor.
RwMySql
Read-write executor pair for MySQL.
RwPostgres
Read-write executor pair for PostgreSQL.
RwSqlite
Read-write executor pair for SQLite.
Sqlite
Type alias for SQLite executor.