[−][src]Trait nsq_client::Subscribe
Allows differents consumers to subscribe to the desired msgs sent by connections.
Example
struct Consumer(pub Addr<Connection>);
impl Actor for Consumer {
type Context = Context<Self>;
fn started(&mut self, ctx: &mut Self::Context) {
self.subscribe::<Msg>(ctx, self.0.clone());
self.subsctibe::<InFligth>(ctx, self.0.clone());
}
}
impl Handler<Msg> for Consumer {
type Result = ();
fn handle(&mut self, msg: Msg, _: &mut Self::Context) {
// process Msg
}
}
impl Handler<InFligth> for Consumer {
type Result = ();
fn handle(&mut self, msg: InFligth, _: &mut Self::Context) {
// do something every time in_fligth is increased or decreased
}
}
Provided methods
fn subscribe<M: NsqMsg>(
&self,
ctx: &mut Self::Context,
addr: Arc<Addr<Connection>>
) where
Self: Handler<M>,
Self::Context: ToEnvelope<Self, M>,
&self,
ctx: &mut Self::Context,
addr: Arc<Addr<Connection>>
) where
Self: Handler<M>,
Self::Context: ToEnvelope<Self, M>,
Implementors
impl<A> Subscribe for A where
A: Actor,
Self::Context: AsyncContext<A>,
[src]
A: Actor,
Self::Context: AsyncContext<A>,
fn subscribe<M: NsqMsg>(
&self,
ctx: &mut Self::Context,
addr: Arc<Addr<Connection>>
) where
Self: Handler<M>,
Self::Context: ToEnvelope<Self, M>,
[src]
&self,
ctx: &mut Self::Context,
addr: Arc<Addr<Connection>>
) where
Self: Handler<M>,
Self::Context: ToEnvelope<Self, M>,