From 77c08845b59504f78d82292b251d266b08752f64 Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Sat, 27 Mar 2021 23:55:26 +0900 Subject: [PATCH] [BUG FIX]Make SearchActor subscribe to channel once --- plume-models/src/search/actor.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/plume-models/src/search/actor.rs b/plume-models/src/search/actor.rs index d71bc53f..d97718e0 100644 --- a/plume-models/src/search/actor.rs +++ b/plume-models/src/search/actor.rs @@ -13,24 +13,22 @@ pub struct SearchActor { impl SearchActor { pub fn init(searcher: Arc, conn: DbPool) { - ACTOR_SYS + let actor = ACTOR_SYS .actor_of_args::("search", (searcher, conn)) .expect("Failed to initialize searcher actor"); - } -} -impl Actor for SearchActor { - type Msg = PostEvent; - - fn pre_start(&mut self, ctx: &Context) { POST_CHAN.tell( Subscribe { - actor: Box::new(ctx.myself()), + actor: Box::new(actor), topic: "*".into(), }, None, ) } +} + +impl Actor for SearchActor { + type Msg = PostEvent; fn recv(&mut self, _ctx: &Context, msg: Self::Msg, _sender: Sender) { use PostEvent::*;