A ConnectRPC-based framework for building microservices in Rust. The name is the Sun's spectral classification (G2V — main-sequence yellow dwarf), not a backronym.
The TypeScript client (
@sunbeam/g2v) moved out of this repository and now lives in the sdk repo atsdk/typescript/. This repository is the Rust framework.
- Service trait —
SunbeamServicewithon_start/on_stophooks and graceful shutdown - Configuration — Figment-based config with env-var support via
ServiceConfig - Server builders —
ServerBuilder→AxumServer(orStandaloneServer) with one-shotserve() - Middleware stack — multitenancy-aware auth (bearer token / session cookie / session token), ReBAC permission enforcement, Prometheus metrics, panic recovery
- Request tracing —
x-request-idhonored/generated/echoed on every request and OpenTelemetry server spans with W3C trace-context propagation, both applied by default - Observability bootstrap —
telemetry::initwirestracingspans into OpenTelemetry and exports OTLP/HTTP to a collector - Database — SQLx Postgres integration with
connect/connect_eagerand automatic migrations - Message queue — NATS / JetStream wrapper (
NatsClient) with stream and consumer helpers - Leader election — Pluggable
LeaderElectiontrait with Vault and NATS implementations - Client resiliency — unified HTTP client with retry (incl. opt-in 401 refresh), circuit breaker, cache, and automatic
x-request-id/ trace-context propagation - Health checks —
HealthRouterexposing/health/liveand/health/ready - Testing —
TestHarness(boots a real server on a random port),MockService, data fixtures, integration tests backed by the sdk's testcontainer builders - Proc-macros —
#[derive(Instrumented)]and#[derive(Metrics)]
cargo add sunbeam-g2vuse sunbeam_g2v::prelude::*;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
// Optional: export traces when OTEL_EXPORTER_OTLP_ENDPOINT is set.
let _telemetry = sunbeam_g2v::telemetry::init(Default::default())?;
let router = ServiceRouter::new();
ServerBuilder::new()
.with_router(router)
.serve()
.await?;
Ok(())
}cargo run --example simpleThe example exposes public, authenticated, and permission-authorized routes
plus a ConnectRPC Eliza service; see examples/simple/main.rs.
.
├── src/ # sunbeam-g2v crate source
├── sunbeam-g2v-derive/ # proc-macro crate (Instrumented, Metrics derives)
├── tests/ # integration tests (sdk testcontainer builders)
├── examples/ # runnable examples
├── proto/ # protobuf definitions
└── docs/ # guides and architecture docs
MIT — see LICENSE.md.