Skip to content

Commit f7a10c4

Browse files
committed
Fix helloworld tutorial.
updated tutorial to use tokio 1.x.
1 parent 729308b commit f7a10c4

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

examples/helloworld-tutorial.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ path = "src/client.rs"
115115
[dependencies]
116116
tonic = "0.4"
117117
prost = "0.7"
118-
tokio = { version = "0.2", features = ["macros"] }
118+
tokio = { version = "1.0", features = ["macros"] }
119119

120120
[build-dependencies]
121121
tonic-build = "0.4"
@@ -179,7 +179,7 @@ impl Greeter for MyGreeter {
179179
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!
180180

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

227-
#[tokio::main]
227+
#[tokio::main(flavor = "current_thread")]
228228
async fn main() -> Result<(), Box<dyn std::error::Error>> {
229229
let addr = "[::1]:50051".parse()?;
230230
let greeter = MyGreeter::default();
@@ -272,7 +272,7 @@ pub mod hello_world {
272272
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:
273273

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

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

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

0 commit comments

Comments
 (0)