[][src]Trait nsq_client::Subscribe

pub trait Subscribe where
    Self: Actor,
    Self::Context: AsyncContext<Self>, 
{ fn subscribe<M: NsqMsg>(
        &self,
        ctx: &mut Self::Context,
        addr: Arc<Addr<Connection>>
    )
    where
        Self: Handler<M>,
        Self::Context: ToEnvelope<Self, M>
, { ... } }

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>, 

Loading content...

Implementors

impl<A> Subscribe for A where
    A: Actor,
    Self::Context: AsyncContext<A>, 
[src]

fn subscribe<M: NsqMsg>(
    &self,
    ctx: &mut Self::Context,
    addr: Arc<Addr<Connection>>
) where
    Self: Handler<M>,
    Self::Context: ToEnvelope<Self, M>, 
[src]

Loading content...