Code Monkey home page Code Monkey logo

ignite-rs's Introduction

Apache Ignite thin client

Usage

[dependencies]
ignite-rs = "0.1.1"
fn main() {
    // Create a client configuration
    let mut client_config = ClientConfig::new("localhost:10800");

    // Optionally define user, password, TCP configuration
    // client_config.username = Some("ignite".into());
    // client_config.password = Some("ignite".into());

    // Create an actual client. The protocol handshake is done here
    let mut ignite = ignite_rs::new_client(client_config).unwrap();

    // Get a list of present caches
    if let Ok(names) = ignite.get_cache_names() {
        println!("ALL caches: {:?}", names)
    }

    // Create a typed cache named "test"
    let hello_cache: Cache<MyType, MyOtherType> = ignite
        .get_or_create_cache::<MyType, MyOtherType>("test")
        .unwrap();

    let key = MyType {
        bar: "AAAAA".into(),
        foo: 999,
    };
    let val = MyOtherType {
        list: vec![Some(FooBar {})],
        arr: vec![-23423423i64, -2342343242315i64],
    };

    // Put value
    hello_cache.put(&key, &val).unwrap();

    // Retrieve value
    println!("{:?}", hello_cache.get(&key).unwrap());
}

// Define your structs, that could be used as keys or values
#[derive(IgniteObj, Clone, Debug)]
struct MyType {
    bar: String,
    foo: i32,
}

#[derive(IgniteObj, Clone, Debug)]
struct MyOtherType {
    list: Vec<Option<FooBar>>,
    arr: Vec<i64>,
}

#[derive(IgniteObj, Clone, Debug)]
struct FooBar {}

Type mapping

Here is the list of supported rust types with corresponding Ignite types and type codes (https://apacheignite.readme.io/docs/binary-client-protocol-data-format)

Rust type Ignite type Ignite type code
u8 Byte 1
u16 Char 7
i16 Short 2
i32 Int 3
i64 Long 4
f32 Float 5
f64 Double 6
bool Bool 8
ignite_rs::Enum Enum 28
String String 9
Vec<u8> ArrByte 12
Vec<u16> ArrChar 18
Vec<i16> ArrShort 13
Vec<i32> ArrInt 14
Vec<i64> ArrLong 15
Vec<f32> ArrFloat 16
Vec<f64> ArrDouble 17
Vec<bool> ArrBool 19
Vec<Option<T>> where T: WritableType + ReadableType Ser => ArrObj; Deser => ArrObj or Collection Ser => 23; Deser => 23 or 24
Option<T> where T: WritableType + ReadableType None => Null; Some => inner type None => 101
User-defined struct ComplexObj 103

User-defined types

You could use your own types as keys/values. All you need to do is to add an #[derive(IgniteObj)] attribute to your struct.

[dependencies]
ignite-rs_derive = "0.1.1"
use ignite_rs_derive::IgniteObj;

#[derive(IgniteObj)]
struct MyOtherType {
    list: Vec<Option<FooBar>>,
    arr: Vec<i64>,
}

WriteableType and ReadableType implementations will be generated for you type. Note, that all fields in your struct should implement WriteableType and ReadableType as well.

SSL/TLS

Encrypted connections are supported via rustls.

[dependencies.ignite-rs]
version = "0.1.1"
features = ["ssl"]
fn main() {

    // Create ssl config
    let ssl_conf: rustls::ClientConfig = ...;
    // Define hostname which certificate should be verified against
    let hostname = String::from("mydomain.com");

    // Create a client configuration
    let mut client_config = ClientConfig::new("localhost:10800", ssl_conf, hostname);
    
    ...
}

ignite-rs's People

Contributors

apohrebniak avatar

Stargazers

roci avatar Yijie Shen avatar Stanislav Mikhailov avatar Price Smith avatar Max avatar

Watchers

Brent Gardner avatar  avatar

ignite-rs's Issues

Is this repo still maintained?

My company will likely be using this library in the future, and I have a fork with some improvements:

  • support for dynamic types
  • sql queries
  • limited transaction support

Should we be creating PRs to this repo? If so will they get published to crates.io? If not, should we publish our fork?

Thanks for creating this library, it was a very helpful head start.

Add LICENSE file

Currently, there is no LICENSE file in this repository. This adds uncertainty for contributors about the legality of various usages, potentially scaring away contributors.

Would it be possible to add a license file? Perhaps with liberal terms such as Apache 2.0 or MIT?

Thanks for all your work on this repo!!!

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.