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
use super::{Group, Way};
use anyhow::Error;
use async_trait::async_trait;
use meio::all::{Context, Eliminated, IdOf};
use meio_connect::server::{HttpServer, HttpServerLink};
use std::net::SocketAddr;

impl Way {
    pub(super) fn spawn_server(
        &mut self,
        addr: SocketAddr,
        group: Group,
        ctx: &mut Context<Self>,
    ) -> HttpServerLink {
        let http_server = HttpServer::new(addr, Some(3));
        ctx.spawn_actor(http_server, group).link()
    }
}

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