Struct Connection

Source
pub struct Connection { /* private fields */ }
Expand description

Tcp Connection to NSQ system.

Tries to connect to nsqd early as started:

§Examples

use actix::prelude::*;
use nsq_client::Connection;

fn main() {
    let sys = System::new("consumer");
    Supervisor::start(|_| Connection::new(
        "test", // <- topic
        "test", // <- channel
        "0.0.0.0:4150", // <- nsqd tcp address
        None, // <- config (Optional)
        None, // <- secret used by Auth
        Some(1) // <- RDY setting for the Connection
    ));
    sys.run();
}

Implementations§

Source§

impl Connection

Source

pub fn new<S: Into<String>>( topic: S, channel: S, addr: S, config: Option<Config>, secret: Option<String>, rdy: Option<u32>, ) -> Connection

Return a Tcp Connection to nsqd.

  • topic - Topic String
  • channel - Channel String
  • addr - Tcp address of nsqd
  • config - Optional Config
  • secret - Optional String used to autenticate to nsqd
  • rdy - Optional initial RDY setting

Trait Implementations§

Source§

impl Actor for Connection

Source§

type Context = Context<Connection>

Actor execution context type
Source§

fn started(&mut self, ctx: &mut Context<Self>)

Method is called when actor get polled first time.
Source§

fn stopping(&mut self, ctx: &mut Self::Context) -> Running

Method is called after an actor is in Actor::Stopping state. There could be several reasons for stopping. Context::stop get called by the actor itself. All addresses to current actor get dropped and no more evented objects left in the context. Read more
Source§

fn stopped(&mut self, ctx: &mut Self::Context)

Method is called after an actor is stopped, it can be used to perform any needed cleanup work or spawning more actors. This is final state, after this call actor get dropped.
Source§

fn start(self) -> Addr<Self>
where Self: Actor<Context = Context<Self>>,

Start new asynchronous actor, returns address of newly created actor. Read more
Source§

fn start_default() -> Addr<Self>
where Self: Actor<Context = Context<Self>> + Default,

Start new asynchronous actor, returns address of newly created actor.
Source§

fn create<F>(f: F) -> Addr<Self>
where Self: Actor<Context = Context<Self>>, F: FnOnce(&mut Context<Self>) -> Self + 'static,

Use create method, if you need Context object during actor initialization. Read more
Source§

impl Default for Connection

Source§

fn default() -> Connection

Returns the “default value” for a type. Read more
Source§

impl Handler<Backoff> for Connection

Source§

type Result = ()

The type of value that this handle will return
Source§

fn handle(&mut self, _msg: Backoff, ctx: &mut Self::Context)

Method is called for every message received by this Actor
Source§

impl Handler<Fin> for Connection

Source§

type Result = ()

The type of value that this handle will return
Source§

fn handle(&mut self, msg: Fin, ctx: &mut Self::Context)

Method is called for every message received by this Actor
Source§

impl Handler<Ready> for Connection

Source§

type Result = ()

The type of value that this handle will return
Source§

fn handle(&mut self, msg: Ready, _ctx: &mut Self::Context)

Method is called for every message received by this Actor
Source§

impl Supervised for Connection

Source§

fn restarting(&mut self, ctx: &mut Self::Context)

Method called when supervisor restarting failed actor
Source§

impl WriteHandler<Error> for Connection

Source§

fn error(&mut self, err: Error, _: &mut Self::Context) -> Running

Method is called when writer emits error. Read more
Source§

fn finished(&mut self, ctx: &mut Self::Context)

Method is called when writer finishes. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<A> Subscribe for A
where A: Actor, <A as Actor>::Context: AsyncContext<A>,

Source§

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Erased for T