akka / akka-edge-rs

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

Introduces the entity manager framework #1

Closed huntc closed 1 year ago

huntc commented 1 year ago

A Rust implementation of Akka Persistence focused on edge-based scenarios. Broad target support, including wasm32-wasi and wasm32-unknown-unknown (browser).

Functionality:

Here's a snippet of code that shows how an entity manager can be assembled and used with Logged:

let commit_log = FileLog::new("/dev/null");

let marshaller = MyEventMarshaler;

let file_log_topic_adapter = FileLogTopicAdapter::new(
    commit_log,
    marshaller,
    "some-consumer".to_string(),
    "some-topic".to_string(),
);

let my_behavior = MyBehavior;

let (_, my_command_receiver) = mpsc::channel(10);

EntityManager::new(my_behavior, file_log_topic_adapter, my_command_receiver);
huntc commented 1 year ago

Another API approach could be more similar to Kalix, with separate annotated methods for each command or event handler, and the event sourced behaviour is derived from these. Not familiar with rust ecosystem, but seems that some rust libraries provide both kinds of approaches — direct APIs and derived APIs.

I’ve kept things in line with Akka Persistence as per Patrick’s prototype code. I think there could be subsequent opportunities for building a field based approach on top if required.

huntc commented 1 year ago

I'm quite pleased with this week. We now have a working entity manager. Please check out the unit tests to check out how things hang together.

One thing that I've not yet quite worked out is how a developer of Akka persistence on the JVM expresses that an entity is to be created... I'm thinking that this could be a user's entity command declared for the purposes of creating an entity. An event should still be emitted. Will think on it more, but it'd be great to get some insights re Akka persistence on the JVM. Thanks.

huntc commented 1 year ago

The PR is now functionally complete and ready for a thorough review.

huntc commented 1 year ago

Got together with @pvlugter . Here's what is going to change by tomorrow: