Giter Club home page Giter Club logo

ksql-db-rs's Introduction

Rust KSQL DB

crates.io docs repo Apache-2.0

This crate is a thin wrapper around the KSQL-DB REST API to make interacting with the API more ergonomic for Rust projects. Under the hood it uses reqwest as a HTTP client to interact with the API.

This project is very much in the early stage and a WIP, so if there are any features or improvements you would like made to it, please raise an issue. Similarly all contributions are welcome.

Up until the point of a v0.2 release the project will not follow semver. Ie. subsequent v0.1-alpha or v0.1-beta releases might include breaking changes, this is to give the library the freedom to improve the API design quickly while still in it's early stages. Once v0.2 is released the project will follow semver.

What is crate is and is not

What the crate is

  • The crate is intended to be an ergonomic way to interact with the provided REST API, this means useful abstractions like futures::Stream are already created for you
  • Provide typed responses and errors instead having to handle response parsing in your application code
  • Be fairly light weight in nature

What this crate is not (currently)

  • It is not a DSL, nor does it intend to do any parsing of SQL statements and compile time

Quickstart

use reqwest::Client;
use ksqldb::KsqlDB;
use futures_util::stream::StreamExt;
use serde::Deserialize;

#[derive(Debug, Deserialize)]
struct MyResponse {
    id: String,
    data: Vec<u32>
}

#[tokio::main]
async fn main() {
    let ksql = KsqlDB::new("localhost:8080".into(), Client::builder(), false).unwrap();

    let statement = r#"SHOW STREAMS EXTENDED;"#;
    let response = ksql.list_streams(&statement, &Default::default(), None).await.unwrap();
    println!("{:#?}", response);

    let query = r#"SELECT * FROM MY_STREAM EMIT CHANGES;"#;

    let mut stream = ksql.select::<MyResponse>(&query, &Default::default()).await.unwrap();

    while let Some(data) = stream.next().await {
        println!("{:#?}", data);
    }
}

Docs

Minimum Supported Version

  • This crate will currently aim to support the latest STABLE release of Rust
  • This crate will aim to keep up to date with the latest stable release of KSQL-DB (currently v0.15)

ksql-db-rs's People

Contributors

naamancurtis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

ibexus-platform

ksql-db-rs's Issues

Add StatementResponse to the api

Hi, just used your crate in https://github.com/gklijs/ksqlDB-GraphQL-poc/tree/main/rust-data-creator which is a wip. It worked great, but for now I just use serde_json::Value as the return type fro the execute_statement. I think it would be nice if the StatementResponse which is already defined in the Examples would be part of the api.

There might be valid reason not to do this. Like it might break, but you could always use another return type if you wish to do so.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.