pub struct Pipeline { /* private fields */ }
Expand description

Pipeline

A pipeline is a way of queing up multiple queries, sending them to the server at once instead of sending them individually, avoiding round-trip-times while also simplifying usage in several places. Responses are returned in the order they are sent.

Example with the sync API

use skytable::{query, Pipeline, Element, RespCode};
use skytable::sync::Connection;

let mut con = Connection::new("127.0.0.1", 2003).unwrap();
let pipe = Pipeline::new()
    .add(query!("set", "x", "100"))
    .add(query!("heya", "echo me!"));

let ret = con.run_pipeline(pipe).unwrap();
assert_eq!(
    ret,
    vec![
        Element::RespCode(RespCode::Okay),
        Element::String("echo me!".to_owned())
    ]
);

Example with the async API

use skytable::{query, Pipeline, Element, RespCode};
use skytable::aio::Connection;

async fn run() {
    let mut con = Connection::new("127.0.0.1", 2003).await.unwrap();
    let pipe = Pipeline::new()
        .add(query!("set", "x", "100"))
        .add(query!("heya", "echo me!"));

    let ret = con.run_pipeline(pipe).await.unwrap();
    assert_eq!(
        ret,
        vec![
            Element::RespCode(RespCode::Okay),
            Element::String("echo me!".to_owned())
        ]
    );
}

Implementations

Initializes a new empty pipeline

Append a query (builder pattern)

Append a query by taking reference

Returns the number of queries in the pipeline

This is supported on crate feature dbg only.

Returns the query packet representation of this pipeline

Panics

This function will panic if the query is empty

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 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.