nitinol-process 0.1.0

Pseudo-actor type process library for Nitinol using green thread of tokio
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use async_trait::async_trait;
use nitinol_core::identifier::EntityId;
use crate::{Context, Receptor};

#[allow(unused_variables)]
#[async_trait]
pub trait Process: 'static + Sync + Send + Sized {
    fn aggregate_id(&self) -> EntityId;
    async fn start(&self, ctx: &mut Context) {}
    async fn stop(&self, ctx: &mut Context) {}
    
    async fn as_ref_self(&self, ctx: &Context) -> Option<Receptor<Self>> {
        ctx.find(&self.aggregate_id()).await
    }
}