[BUG FIX]Make SearchActor subscribe to channel once

This commit is contained in:
Kitaiti Makoto 2021-03-27 23:55:26 +09:00
parent 2bfc26faf2
commit 77c08845b5

View File

@ -13,24 +13,22 @@ pub struct SearchActor {
impl SearchActor { impl SearchActor {
pub fn init(searcher: Arc<Searcher>, conn: DbPool) { pub fn init(searcher: Arc<Searcher>, conn: DbPool) {
ACTOR_SYS let actor = ACTOR_SYS
.actor_of_args::<SearchActor, _>("search", (searcher, conn)) .actor_of_args::<SearchActor, _>("search", (searcher, conn))
.expect("Failed to initialize searcher actor"); .expect("Failed to initialize searcher actor");
}
}
impl Actor for SearchActor {
type Msg = PostEvent;
fn pre_start(&mut self, ctx: &Context<Self::Msg>) {
POST_CHAN.tell( POST_CHAN.tell(
Subscribe { Subscribe {
actor: Box::new(ctx.myself()), actor: Box::new(actor),
topic: "*".into(), topic: "*".into(),
}, },
None, None,
) )
} }
}
impl Actor for SearchActor {
type Msg = PostEvent;
fn recv(&mut self, _ctx: &Context<Self::Msg>, msg: Self::Msg, _sender: Sender) { fn recv(&mut self, _ctx: &Context<Self::Msg>, msg: Self::Msg, _sender: Sender) {
use PostEvent::*; use PostEvent::*;