transit¶
Shared HTTP & gRPC transport middleware for Go services — structured request logging, OpenTelemetry instrumentation, circuit breaking, rate limiting and client retry, from one framework-free module.
gitlab.com/phpboyscout/go/transit gives a service's HTTP and gRPC edges a single,
shared implementation of the cross-cutting transport concerns — the same logging,
tracing, circuit-breaking and rate-limiting behaviour whether the traffic arrives over
REST or gRPC, and whether the code is a server accepting calls or a client making them.
It is the middleware layer extracted from
go-tool-base.
Why¶
- Framework-free. It carries the gRPC SDK and the OpenTelemetry gRPC/HTTP contrib
instrumentation — that is the middleware's job — but nothing else. A
depfootprint_test.goguard forbids go-tool-base, Viper/Cobra, Charm and the cloud SDKs; the remaining dependencies aregolang.org/x/time/rate, go/redact andcockroachdb/errors. *slog.Loggerat the seam. Every middleware that logs takes a plain*slog.Logger, so nothing here pulls in a logging framework.- Server and client, both transports.
httpandgrpceach provide server handlers/interceptors and client round-trippers/interceptors, so a service and the clients it calls share one implementation of each concern. See the middleware model. - Resilience is one package. The circuit breaker and the keyed token-bucket
rate-limiter store live in
resilience; the HTTP and gRPC layers wrap them into transport-shaped middleware.
Where next¶
- Getting started — a logged, traced HTTP handler in a dozen lines.
- Compose HTTP middleware — server chains and client round-trippers (retry, circuit breaker, auth).
- Compose gRPC interceptors — server interceptor chains and client instrumentation.
- The middleware model — chain ordering, client vs server, and why retry sits inside the breaker.
- API reference — full godoc on pkg.go.dev.
Part of the phpboyscout Go toolkit — small, framework-free Go modules extracted from go-tool-base.