Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ServiceRegistrar ¶
type ServiceRegistrar struct {
// contains filtered or unexported fields
}
ServiceRegistrar is the cell-facing gRPC service registration seam. It is constructed by adapters/grpc.Server.Registrar() and handed to bootstrap which calls Register(spec) for each GRPCServiceSpec drained from the cell snapshot. The grpc.ServiceRegistrar interface is NOT exported — the only entry point is Register(spec), which routes through the attribution-aware cellScopedRegistrar interceptor.
All public methods are safe for concurrent use after construction.
func NewServiceRegistrar ¶
func NewServiceRegistrar() *ServiceRegistrar
NewServiceRegistrar builds a ServiceRegistrar with an empty attribution map and no delegation target (two-phase, Option 3 #1152). The composition root creates it FIRST so reg.CellIDForMethod can be handed to the unary interceptor chain — which is composed BEFORE the gRPC server exists — and binds the delegation target via BindServer once grpc.NewServer has been constructed with that chain. CellIDForMethod is callable immediately (the map exists from construction); it returns matches once Register has populated it during the bootstrap drain.
func (*ServiceRegistrar) BindServer ¶
func (r *ServiceRegistrar) BindServer(inner grpc.ServiceRegistrar)
BindServer sets the delegation target (typically *grpc.Server) that Register forwards RegisterService calls to. It must be called exactly once, during adapter construction, before any Register call (the bootstrap drain runs in phase7b, after New returns). inner must not be nil and BindServer must not be called twice — both are B-class programmer errors raised via panicregister.Approved.
func (*ServiceRegistrar) CellIDForMethod ¶
func (r *ServiceRegistrar) CellIDForMethod(fullMethod string) (string, bool)
CellIDForMethod returns the cellID attributed to fullMethod (e.g. "/grpc.health.v1.Health/Check"). The second return value is false when the method has not been registered via Register. Safe for concurrent use.
func (*ServiceRegistrar) Register ¶
func (r *ServiceRegistrar) Register(spec cell.GRPCServiceSpec) error
Register invokes the spec.Register callback via an attribution-aware, single-use cellScopedRegistrar interceptor, then records every method/stream exposed by the registered service under spec.CellID.
This implementation always returns nil; every contract violation panics via panicregister.Approved (B-class programmer / config error, fail-fast at startup — the drain runs in phase7b before any RPC is served):
- spec.Register is not a func(grpc.ServiceRegistrar): panicregister.Approved("grpc-registrar-bad-register-fn", …).
- spec.Register is a typed-nil callback (a nil func(grpc.ServiceRegistrar) boxed in any — passes kernel's bare-nil Validate but is uninvokable): panicregister.Approved("grpc-registrar-nil-register-fn", …).
- the callback does not register exactly one service (zero = silently unserved spec; >1 = a single spec smuggling multiple services): panicregister.Approved("grpc-registrar-service-count", …).
- the callback registers a ServiceName already owned by another spec (cross-cell collision): panicregister.Approved("grpc-registrar-dup-service", …) before grpc-go's own fatal — with first/current owner context.
- the cellScopedRegistrar is retained and used after the callback returns (escaped scope — would let registration leak past Serve): panicregister.Approved("grpc-registrar-escaped-scope", …).
Register must be called before grpcServer.Serve (enforced by the drain ordering: bootstrap calls Register in phase7b before grpcServeAll). The scope is closed once the callback returns so a retained registrar cannot register after Serve.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package interceptor provides the gRPC unary server interceptor chain that aligns the gRPC transport with the existing HTTP middleware stack (runtime/http/middleware): RequestID, CellAttribution, Tracing, AccessLog, Metrics, Auth, and Recovery.
|
Package interceptor provides the gRPC unary server interceptor chain that aligns the gRPC transport with the existing HTTP middleware stack (runtime/http/middleware): RequestID, CellAttribution, Tracing, AccessLog, Metrics, Auth, and Recovery. |