Skip to content

A simple project implementation grpc in Rust using tonic and prost, based on Let's Get Rusty tutorial.

License

Notifications You must be signed in to change notification settings

jcbritobr/grpc-sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple gRPC Client and Server using Rust

A simple project implementation grpc in Rust using tonic and prost, based on Let's Get Rusty tutorial.

  • Project setup

    [package]
    name = "grpc-sample"
    version = "0.1.0"
    edition = "2021"
    
    # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
    
    [[bin]]
    name = "client"
    path = "src/client.rs"
    
    [[bin]]
    name = "server"
    path = "src/server.rs"
    
    [dependencies]
    tonic = "*"
    prost = "*"
    tokio = {version = "*", features = ["macros", "rt-multi-thread"]}
    
    [build-dependencies]
    tonic-build = "*"
  • Tonic build automation

    fn main() -> Result<(), Box<dyn std::error::Error>> {
        tonic_build::compile_protos("proto/payments.proto")?;
        Ok(())
    }
  • Execute server

     $ cargo run --bin server
    
  • Execute client

    $ cargo run --bin client
    response Response { metadata: MetadataMap { headers: {"content-type": "application/grpc", "date": "Thu, 03 Nov 2022 13:27:53 GMT", "grpc-status": "0"} }, message: BtcPaymentResponse { successful: true, message: "Sent 22BTC to 654321" }, extensions: Extensions }
    

About

A simple project implementation grpc in Rust using tonic and prost, based on Let's Get Rusty tutorial.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages