Module tarantool::network::client

source ·
Expand description

Tarantool based async Client.

Can be used only from inside Tarantool as it makes heavy use of fibers and coio.

§Example

use tarantool::network::client::Client;
// Most of the client's methods are in the `AsClient` trait
use tarantool::network::client::AsClient as _;

let client = Client::connect("localhost", 3301).await.unwrap();
client.ping().await.unwrap();

// Requests can also be easily combined with fiber::r#async::timeout
use tarantool::fiber::r#async::timeout::IntoTimeout as _;
use std::time::Duration;

client.ping().timeout(Duration::from_secs(10)).await.unwrap();

§Reusing Connection

Client can be cloned, and safely moved to a different fiber if needed, to reuse the same connection. When multiple fibers use the same connection, all requests are pipelined through the same network socket, but each fiber gets back a correct response. Reducing the number of active sockets lowers the overhead of system calls and increases the overall server performance.

§Implementation

Internally the client uses Protocol to get bytes that it needs to send and push bytes that it gets from the network.

On creation the client spawns sender and receiver worker threads. Which in turn use coio based TcpStream as the transport layer.

Modules§

Structs§

  • Actual client that can be used to send and receive messages to tarantool instance.

Enums§

Traits§

  • Generic API for an entity that behaves as Tarantool Client.