Giter VIP home page Giter VIP logo

pb-nats-rs's Introduction

pb-nats-rs

This is a simple rpc client impl to work with protobuf-nats. This uses tower to add service layers.

Do not use in production. This is for learning.

Example:

#[tokio::main]
async fn main() {
    let address = "127.0.0.1:4222".parse().unwrap();
    let client = Client::new(vec![address]);
    client.connect().await;

    let rpc_client_srv = rpc::RpcClient::new(client.clone());
    let rpc_client = ServiceBuilder::new()
        .buffer(100)
        .concurrency_limit(100)
        .service(rpc_client_srv.clone());

    println!("Started!");
    let sc = ShipmentClient {
        rpc_client: rpc_client,
    };
    let req = ShipmentRequest::new();
    let mut res: Shipments = sc.search(req).await.unwrap();
    let mut shipment: Shipment = res.take_records().pop().unwrap();
    println!("Response: {:?}", shipment);
}

This will output something like:

Started!
Response: guid: "165e8b52-c3bf-4871-82b6-b2d0db30936a" address: "123 LAME ST" price: 100 package_guid: "16b37958-8ed4-4756-8e1f-f6440522c57d"

License: MIT

pb-nats-rs's People

Contributors

film42 avatar

Watchers

James Cloos avatar  avatar

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.