Skip to main content

Crate autumn_plugin_grpc

Crate autumn_plugin_grpc 

Source
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 grpc indicator in /actuator/health,
  • grpc_server_* metrics in /actuator/prometheus,
  • AppState in 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§

ClientConfig
Settings for one downstream gRPC service ([grpc.clients.<name>]). Needs the client feature.
ClientTls
Client TLS settings. Empty values mean “not set”.
ConfigError
A configuration problem. Boot stops. The plugin does not fall back to defaults.
GrpcConfig
Settings for one gRPC server.
GrpcHandle
A handle to the gRPC server of one plugin.
GrpcPlugin
Serves tonic services from an Autumn app, on a dedicated HTTP/2 listener or on Autumn’s HTTP port (listener = "shared").
GrpcServers
The gRPC servers of one app, by config section.
LifecycleCell
A Lifecycle shared between threads. It changes only through Lifecycle::next.
Resolved
A resolved configuration and the active profile.
TlsConfig
TLS settings. Needs the tls crate feature.

Enums§

GrpcError
A startup failure. Each one aborts boot.
Lifecycle
The state of one gRPC server.
LifecycleEvent
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-web series this release is tested with.