Expand description
hermes-server is the server-side crate for the Hermes gRPC event broker.
It provides:
- a broker engine with fanout and queue-group delivery
- a gRPC service implementation (via
tonic) - optional durable delivery with redelivery + garbage-collection loops
§Quick start
Run a server from a bound TcpListener:
use tokio::net::TcpListener;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let listener = TcpListener::bind("127.0.0.1:4222").await?;
hermes_server::run(listener).await?;
Ok(())
}Run with explicit configuration:
use tokio::net::TcpListener;
use hermes_server::config::ServerConfig;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let listener = TcpListener::bind("127.0.0.1:4222").await?;
let mut cfg = ServerConfig::default();
cfg.subscriber_channel_capacity = 16_384;
cfg.store_path = Some("hermes.redb".into());
hermes_server::run_with_config(listener, cfg).await?;
Ok(())
}§Configuration
The server can be configured programmatically with config::ServerConfig and can
also be initialized from environment variables through ServerConfig::from_env().
Useful env vars include:
HERMES_LISTEN_ADDRHERMES_CHANNEL_CAPACITYHERMES_GRPC_OUTPUT_BUFFERHERMES_STORE_PATHHERMES_REDELIVERY_INTERVALHERMES_MAX_DELIVERY_ATTEMPTSHERMES_RETENTION_SECSHERMES_ACK_TIMEOUTHERMES_MAX_IN_FLIGHTHERMES_GC_INTERVALHERMES_REDELIVERY_BATCH_SIZE
§Notes
- If
store_pathisNone, the server runs in fire-and-forget mode (no durable redelivery persistence). - If
store_pathis set, durable store-backed redelivery and GC loops are spawned.
Modules§
Functions§
- run
- Run the broker server on the given listener (runs until the process is killed). Useful for integration tests that need a server on a random port.
- run_
with_ config - Run the broker server with a specific config (runs until the process is killed).
- run_
with_ shutdown - Run the broker server with graceful shutdown.