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/httpandpkg/grpcstill 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, theInterceptor/InterceptorChaintypes,LoggingInterceptor,OTelStatsHandler, and the rest — resolves exactly as before. - The
internal/circuitbreakerandinternal/ratelimitprimitives now live intransit/resilience. - The GTB-specific pieces stay in go-tool-base: the secure HTTP client constructor
(
NewClientand itsWithRetry/WithClientMiddlewareoptions), 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 aWithRetryoption). GTB'spkg/httpkeepsWithRetry(cfg)as aNewClientoption — it wiresNewRetryTransportfor you — soNewClient(WithRetry(...))is unchanged. - Full documentation and the middleware model live at transit.go.phpboyscout.uk; the API reference is on pkg.go.dev.