Skip to content

Migration: transport middleware → go/transit

The shared HTTP and gRPC transport middleware — structured request logging, OpenTelemetry instrumentation, circuit breaking, rate limiting and client retry, plus the underlying circuit-breaker and rate-limiter primitives — has been extracted out of go-tool-base into the standalone module gitlab.com/phpboyscout/go/transit (v0.1.0). It is framework-free: it carries the gRPC SDK and the OpenTelemetry gRPC/HTTP contrib instrumentation but nothing else.

What changed

  • Nothing changes for GTB consumers. pkg/http and pkg/grpc still exist and their public API is identical. They are now thin adapters that re-export the transit middleware (a facade), so every existing symbol — NewChain, LoggingMiddleware, OTelMiddleware, RateLimitMiddleware, WithCircuitBreaker, NewClientChain, WithBearerToken, the Interceptor/InterceptorChain types, LoggingInterceptor, OTelStatsHandler, and the rest — resolves exactly as before.
  • The internal/circuitbreaker and internal/ratelimit primitives now live in transit/resilience.
  • The GTB-specific pieces stay in go-tool-base: the secure HTTP client constructor (NewClient and its WithRetry/WithClientMiddleware options), the config-key adapters (RateLimitConfigFromConfig, CircuitBreakerConfigFromConfig), the server bootstraps (NewServer/Register) and request authentication.

How to migrate

If you consume go-tool-base's pkg/http or pkg/grpc, do nothing — upgrade as usual and your imports keep working.

If you want the transport middleware without the framework, depend on the module directly:

go get gitlab.com/phpboyscout/go/[email protected]
import (
    transithttp "gitlab.com/phpboyscout/go/transit/http"
    transitgrpc "gitlab.com/phpboyscout/go/transit/grpc"
)

Notes

  • One rename at the module boundary: the retry round-tripper is now constructed with NewRetryTransport(next, cfg) (transit does not own the client constructor, so it exposes the transport rather than a WithRetry option). GTB's pkg/http keeps WithRetry(cfg) as a NewClient option — it wires NewRetryTransport for you — so NewClient(WithRetry(...)) is unchanged.
  • Full documentation and the middleware model live at transit.go.phpboyscout.uk; the API reference is on pkg.go.dev.