Skip to content

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.

go get gitlab.com/phpboyscout/go/transit

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.go guard forbids go-tool-base, Viper/Cobra, Charm and the cloud SDKs; the remaining dependencies are golang.org/x/time/rate, go/redact and cockroachdb/errors.
  • *slog.Logger at the seam. Every middleware that logs takes a plain *slog.Logger, so nothing here pulls in a logging framework.
  • Server and client, both transports. http and grpc each 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


Part of the phpboyscout Go toolkit — small, framework-free Go modules extracted from go-tool-base.