Crates.io | actix-web-tonic |
lib.rs | actix-web-tonic |
version | 1.0.0 |
source | src |
created_at | 2022-05-02 03:35:50.848639 |
updated_at | 2022-05-02 03:35:50.848639 |
description | actix-web and tonic concurrent runner |
homepage | |
repository | https://github.com/usagi/actix-web-tonic |
max_upload_size | |
id | 578846 |
size | 11,572 |
!(image1)[https://imgur.com/5qaPfr3.png]
actix-web-tonic
is the concurrent runner of actix-web
+ tonic
.actix-web
server same as basically coding, and get the future:let actix_future = HttpServer::new(|| { App::new().service(...
...brabrabra...
.bind("[::1]:50000").unwrap()
.workers(8) // <- # of workers setting is here in actix-web.
.run(); // <- this type is `Service`, it's an `impl` of `Future`.
Implement your tonic
server same as basically coding, and get the future:
let tonic_future = Server::builder().add_service(...
...brabrabra...
...serve(addr); // <- this type is a simple `Future` of `asyncl`.
let tonic_worker_threads = 16; // <- # of workers setting is here in tonic.(=# of tokio workers)
let result = actix_web_tonic::invoke(actix_future, tonic_future, tonic_worker_threads);
And then, test your server:
# gRPC:
$ grpcurl -plaintext -import-path ./proto -proto helloworld.proto -d '{"name": "Tonic"}' '[::1]:50001' helloworld.Greeter/SayHello
{
"message": "Hello Tonic!"
}
# Web:
$ curl '[::1]:50000/teapot' -v
* Trying ::1:50000...
* TCP_NODELAY set
* Connected to ::1 (::1) port 50000 (#0)
> GET /teapot HTTP/1.1
> Host: [::1]:50000
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 418 I'm a teapot
< content-length: 23
< date: Sun, 01 May 2022 23:29:41 GMT
<
* Connection #0 to host ::1 left intact
I like a green tea.🍵%
future
of me, and ofcourse you who looks this crate.💕