Crate nsq_client

Source
Expand description

Nsq-client is the actix based client implementation of the nsq protocol.

This crate is intended as a swiss-knife base implementation for more complex nsq client applications, it supports even single or multiple connections, single or multiple async readers.

Due the actors model, readers and connections are distinct entities witch communicate each other throught messages, so one reader could receive messages from multiple connections and multiple connections could easily send messages to multiple readers.

§Examples

use actix::prelude::*;
use nsq_client::{Connection, Msg, Subscribe, Fin};

struct MyReader{
    conn: Arc<Addr<Connection>>,
};

impl Actor for MyReader {
    type Context = Context<Self>;
    fn started(&mut self, _: &mut Self::Context) {
        self.subscribe::<Msg>(ctx, self.conn.clone());
    }
}

impl Handler<Msg> for MyReader {
    type Result = ();
    fn handle(&mut self, msg: Msg, ctx: &mut Self::Context) {
        let conn = msg.conn.clone();
        let msg = msg.msg;
        info!("MyReader received: {:?}", msg);
        conn.do_send(Fin(msg.id));
    }
}

Structs§

Backoff
Allows Consumer to set Connection on backoff state
Config
Configuration sent to nsqd to properly config the Connection
Connection
Tcp Connection to NSQ system.
Fin
Send FIN command to nsqd
InFlight
Sent by Connection every time in_fligth is increased or decreased
Msg
Message sent by nsqd
OnAuth
Sent by Connection if auth be successful
OnBackoff
Sent by Connection after Backoff state is activated
OnClose
Sent by Connection after CLS is sent to nsqd
OnIdentify
Sent by Connection after identify succeeds
OnResume
Sent by Connection after Backoff state is terminated
Producer
Pub
Ready
Allows Consumer to change Connection/s RDY
Reqeue
Send REQ command to nsqd
Touch
Send TOUCH command to nsqd (reset timeout for and in-flight message)

Enums§

Error

Traits§

Subscribe
Allows differents consumers to subscribe to the desired msgs sent by connections.