1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use super::{Group, Way};
use anyhow::Error;
use async_trait::async_trait;
use meio::all::{Context, Eliminated, IdOf};
use meio_connect::server::HttpServerLink;
use rill_engine::{RillEngine, RillEngineLink};

impl Way {
    pub(super) async fn spawn_engine(
        &mut self,
        server: HttpServerLink,
        ctx: &mut Context<Self>,
    ) -> Result<(), Error> {
        let pair = RillEngineLink::take_global_address_pair().await?;
        let engine = RillEngine::new(server);
        ctx.spawn_actor_with_addr(engine, pair, Group::Engine);
        Ok(())
    }
}

#[async_trait]
impl Eliminated<RillEngine> for Way {
    async fn handle(
        &mut self,
        _id: IdOf<RillEngine>,
        _ctx: &mut Context<Self>,
    ) -> Result<(), Error> {
        log::info!(target: &self.log_target, "RillEngine finished");
        Ok(())
    }
}