Struct nsq::consumer::Consumer
[−]
[src]
pub struct Consumer { /* fields omitted */ }
Consumer
represents a long-lived connection to an nsqd instance that can read messages
and reply depending on a handler function.
Methods
impl Consumer
[src]
fn new(topic: &str, channel: &str, config: NsqConfig) -> Consumer
Given a topic, channel, and config, set up a new Consumer instance.
fn connect_to_nsqd<A: ToSocketAddrs>(&mut self, addr: A) -> NsqResult<()>
Connect to a single nsqd instance supplied with a host and port.
fn add_handler<H>(&mut self, handler: H) where
H: Handler + 'static,
H: Handler + 'static,
Add a handler for messages that are consumed.
fn begin_consuming(self) -> NsqResult<()>
Start consuming from nsqd by initiating an event loop. This function moves the consumer to take ownership of the internal connection.