akka / akka-edge-rs

Akka Edge support in Rust
https://doc.akka.io/docs/akka-edge/current/
Other
9 stars 1 forks source link

Two offset stores in play #75

Closed huntc closed 1 year ago

huntc commented 1 year ago

When consuming a projection, we have two offset stores in play.

The first, commit-log-based offset store is provided to the GrpcSourceProvider:

    let event_producer = Channel::builder(event_producer_addr);
    let source_provider =
        GrpcSourceProvider::new(|| event_producer.connect(), stream_id, offset_store);

The source provider will use this offset store to validate each entity's seq_nr.

The next offset store is further down when running the projection:

    akka_projection_rs_storage::run(
        &secret_store,
        &offsets_key_secret_path,
        &state_storage_path,
        kill_switch,
        source_provider,
        handler,
        Duration::from_millis(100),
    )
    .await

... where the first three params, and last param are supplied so the projection can both source and save the last offset processed from and to a file.

The above can be simplified by supplying the offset store to just the projection, and also providing a load_event method on the source provider. This will then permit the projection to validate entity seq_nrs in place of the source provider doing it; which would also be consistent with the approach the JVM code takes.