Skip to content

alexandrebouthinon/kuzzle-rs

Repository files navigation

GitHub Workflow Status

Usage

The SDK supports different protocols. When instantiating, you must choose the protocol to use and fill in the different options needed to connect to Kuzzle.

use kuzzle::protocols::WebSocket;
use kuzzle::{request, Kuzzle};

#[async_std::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut k = Kuzzle::new(WebSocket::new("localhost", None));
    k.connect().await?;

    let request = request!({
        "controller": "server",
        "action": "now"
    })?;

    let response = k.query(&request).await?;

    match response.get_result() {
        Some(result) => println!("Kuzzle current Epoc timestamp: {}", &result["now"]),
        None => eprintln!("No timestamp was reveived from the Kuzzle server!"),
    }

    k.disconnect().await
}

About

Kuzzle

Kuzzle is an open-source backend that includes a scalable server, a multiprotocol API, an administration console and a set of plugins that provide advanced functionalities like real-time pub/sub, blazing fast search and geofencing.

Releases

No releases published

Packages

No packages published

Languages