Struct rants::Client[][src]

pub struct Client { /* fields omitted */ }
Expand description

The entry point to the NATS client protocol

Implementations

Create a new Client with a default Connect

Arguments
  • addresses - the list of addresses to try and establish a connection to a server

Create a new Client with the provided Connect

Arguments
  • addresses - the list of addresses to try and establish a connection to a server

Get the current state of the Client

Get a watch stream of Client state transitions

Get a the most recent Info sent from the server

Get a mutable reference to this Client’s Connect

Get a mutable reference to the list of addresses used to try and establish a connection to a server.

Get the configured TCP connect timeout. [default = 10s]

This is the timeout of a single connect attempt. It is not the timeout of the connect future which has no internal timeout.

Set the TCP connect timeout.

Get the DelayGenerator

The default generator is generated with generate_delay_generator with the following parameters:

  • connect_series_attempts_before_cool_down = 3
  • connect_delay = 0s
  • connect_series_delay = 5s
  • cool_down = 60s

Get a list of all currently subscribed subscription IDs

Return a reference to a Subscription if the client is aware of the specified subscription ID

Send a CONNECT message to the server using the configured Connect.

Note: connect automatically sends a CONNECT message. This is only needed in the case that you want to change the connection parameters after already establishing a connection.

Connect to a NATS server

This will randomly shuffle a list consisting of all explicitly specified addresses and addresses received in an INFO message’s connect_urls. A randomized list of addresses is used to avoid a thundering herd. The client will continuously try to connect to each address in this list. The timeout of each connect attempt is specified by the tcp_connect_timeout. The delay between each connect attempt is specified by the delay_generator_mut.

When this future resolves, we are guaranteed to have entered the Connected state. Unless, disconnect was called.

Should the client become disconnected for any reason, other than calling disconnect, the client will continuously try to reconnect. Upon a successful reconnect, the client will automatically subscribe to all subscriptions.

Disconnect from the NATS server

When this future resolves, we are guaranteed to have entered the Disconnected state.

Note: Client does not disconnect when it is Dropped. In order to avoid leaking futures, you must explicitly call disconnect.

Convenience wrapper around publish_with_optional_reply

Convenience wrapper around publish_with_optional_reply

PUBlish a message

Arguments
  • subject - The subject to publish to
  • reply_to - The optional reply to subject
  • payload - The actual contents of the message

Implements the request-reply pattern

Implements the request-reply pattern with a timeout

Convenience wrapper around subscribe_with_optional_queue_group

Convenience wrapper around subscribe_with_optional_queue_group

SUBscribe to a Subject

Returns the subscription ID of the newly created subscription and a channel to receive incoming messages on.

Arguments
  • subject - The subject to subscribe to
  • reply_to - The optional queue group to join
  • buffer - The size of the underlying mpsc channel

Convenience wrapper around unsubscribe_optional_max_msgs

Convenience wrapper around unsubscribe_optional_max_msgs

UNSUBscribe from a subscription ID

Arguments
  • sid - The subscription id to unsubscribe from
  • max_msgs - Unsubscribe after receiving the specified number of messages. If this is None, the subscription is immediately unsubscribed.

Unsubscribe from all subscriptions

Get a watch stream of INFO messages received from the server

Get a watch stream of PING messages received from the server

Get a watch stream of PONG messages received from the server

Get a watch stream of +OK messages received from the server

Get a watch stream of -ERR messages received from the server

Send a PING to the server.

This method, coupled with a pong_stream, can be a useful way to check that the client is still connected to the server.

Send a PONG to the server.

Note: you do not have to manually send a PONG as part of the servers ping/pong keep alive. The client library automatically handles replying to pings. You should not need to use this method.

Send a PONG and wait for a PONG from the server

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.