grpc

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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(inner grpc.ServiceRegistrar) *ServiceRegistrar

NewServiceRegistrar wraps inner (typically *grpc.Server) into a ServiceRegistrar. inner must not be nil — both bare-nil and typed-nil are rejected with a panicregister.Approved("grpc-registrar-nil-inner", …) panic (B-class programmer error).

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, Tracing, 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, Tracing, Metrics, Auth, and Recovery.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL