Expand description
gRPC for Autumn, built on tonic.
ⓘ
use autumn_plugin_grpc::GrpcPlugin;
#[autumn_web::main]
async fn main() {
autumn_web::app()
.routes(routes![index])
.plugin(GrpcPlugin::new().add_service(GreeterServer::new(MyGreeter)))
.run()
.await;
}The plugin runs a dedicated HTTP/2 listener (default 0.0.0.0:50051).
With the multiplex feature and listener = "shared", it uses
Autumn’s HTTP port instead. It adds:
- the standard health service
grpc.health.v1.Health, - server reflection (on in
dev/test), - a
grpcindicator in/actuator/health, grpc_server_*metrics in/actuator/prometheus,AppStatein each request’s extensions,- graceful drain on shutdown.
With the client feature, handlers call other gRPC services with
GrpcClient and GrpcClients ([grpc.clients.<name>]).
See GrpcConfig for the [grpc] section of autumn.toml.
Re-exports§
pub use tonic;pub use tonic_health;pub use tonic_reflection;
Structs§
- Client
Config - Settings for one downstream gRPC service (
[grpc.clients.<name>]). Needs theclientfeature. - Client
Tls - Client TLS settings. Empty values mean “not set”.
- Config
Error - A configuration problem. Boot stops. The plugin does not fall back to defaults.
- Grpc
Config - Settings for one gRPC server.
- Grpc
Handle - A handle to the gRPC server of one plugin.
- Grpc
Plugin - Serves tonic services from an Autumn app, on a dedicated HTTP/2 listener
or on Autumn’s HTTP port (
listener = "shared"). - Grpc
Servers - The gRPC servers of one app, by config section.
- Lifecycle
Cell - A
Lifecycleshared between threads. It changes only throughLifecycle::next. - Resolved
- A resolved configuration and the active profile.
- TlsConfig
- TLS settings. Needs the
tlscrate feature.
Enums§
- Grpc
Error - A startup failure. Each one aborts boot.
- Lifecycle
- The state of one gRPC server.
- Lifecycle
Event - An input to the state machine.
- Listener
- Where the gRPC server listens.
- Toggle
- A three-state switch. In TOML, write a boolean or
"auto".
Constants§
- DEFAULT_
SECTION - The default config section.
- PLUGIN_
NAME - The name in
Plugin::name, logs and errors. - SUPPORTED_
AUTUMN_ WEB - The
autumn-webseries this release is tested with.