nitinol-sqlite-adaptor

Crates.ionitinol-sqlite-adaptor
lib.rsnitinol-sqlite-adaptor
version0.1.0
created_at2025-03-25 07:38:20.345005+00
updated_at2025-03-25 07:38:20.345005+00
descriptionSQLite storage adapter for `nitinol-persistence`.
homepage
repository
max_upload_size
id1604917
size80,020
RechellaTek (HalsekiRaika)

documentation

README

nitinol-sqlite-adaptor

This is a simple adaptor to use Nitinol with SQLite databases.

Usage

#[tokio::test]
async fn main() -> anyhow::Result<()> {
    // Initialize the sqlite inmemory eventstore
    let eventstore = SqliteEventStore::setup("sqlite://:memory:").await?;
    
    // Initialize the event writer
    let writer = EventWriter::new(eventstore.clone()).set_retry(5);
    
    // Install writer into global
    nitinol::setup::set_writer(writer);
    
    // It is recommended that the actual saving method 
    // be done at the beginning of the EventApplicator process.
    // 
    // #[async_trait]
    // impl EventApplicator<EntityEvent> for Entity {
    //     #[tracing::instrument(skip_all)]
    //     async fn apply(&mut self, event: EntityEvent, ctx: &mut Context) {
    //         self.persist(&event, ctx).await;
    //         
    //         match event {
    //             EntityEvent::Created => {
    //                 tracing::debug!("Entity created.");
    //             }
    //         }
    //     }
    // }
}
Commit count: 0

cargo fmt