Skip to content

Commit

Permalink
Fix helloworld tutorial.
Browse files Browse the repository at this point in the history
updated tutorial to use tokio 1.x.
  • Loading branch information
16yuki0702 committed Jan 27, 2021
1 parent 729308b commit f7a10c4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions examples/helloworld-tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ path = "src/client.rs"
[dependencies]
tonic = "0.4"
prost = "0.7"
tokio = { version = "0.2", features = ["macros"] }
tokio = { version = "1.0", features = ["macros"] }

[build-dependencies]
tonic-build = "0.4"
Expand Down Expand Up @@ -179,7 +179,7 @@ impl Greeter for MyGreeter {
Finally, let's define the Tokio runtime that our server will actually run on. This requires Tokio to be added as a dependency, so make sure you included that!

```rust
#[tokio::main]
#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let addr = "[::1]:50051".parse()?;
let greeter = MyGreeter::default();
Expand Down Expand Up @@ -224,7 +224,7 @@ impl Greeter for MyGreeter {
}
}

#[tokio::main]
#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let addr = "[::1]:50051".parse()?;
let greeter = MyGreeter::default();
Expand Down Expand Up @@ -272,7 +272,7 @@ pub mod hello_world {
The client is much simpler than the server as we don't need to implement any service methods, just make requests. Here is a Tokio runtime which will make our request and print the response to your terminal:

```rust
#[tokio::main]
#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut client = GreeterClient::connect("http://[::1]:50051").await?;

Expand All @@ -298,7 +298,7 @@ pub mod hello_world {
tonic::include_proto!("helloworld");
}

#[tokio::main]
#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut client = GreeterClient::connect("http://[::1]:50051").await?;

Expand Down

0 comments on commit f7a10c4

Please sign in to comment.