Documentation
¶
Index ¶
- type Config
- type GRPCMetrics
- type GRPCRegistrar
- type MetricsContributor
- type Option
- type Server
- func (t *Server[T]) BuildConfig() (app.Materializer, error)
- func (t *Server[T]) Deps() []any
- func (t *Server[T]) DisableGate()
- func (t *Server[T]) HealthCheck(_ context.Context) error
- func (t *Server[T]) Inject(args []any)
- func (t *Server[T]) ProbeReady(ctx context.Context) error
- func (t *Server[T]) Start(ctx context.Context) (func(context.Context) error, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config[T GRPCRegistrar] struct { Label common.Label Host common.Host Port common.Port // contains filtered or unexported fields }
Config is the gRPC server spec (Label, Host, Port); ecfg fills before Build.
type GRPCMetrics ¶
type GRPCMetrics struct {
// contains filtered or unexported fields
}
GRPCMetrics is a singleton pool resource: contributor + shared prometheus interceptors for all srv-grpc servers.
func (*GRPCMetrics) InitializeMetrics ¶
func (m *GRPCMetrics) InitializeMetrics(s *grpc.Server)
func (*GRPCMetrics) RegisterMetrics ¶
func (m *GRPCMetrics) RegisterMetrics(reg *prom.Registry) error
func (*GRPCMetrics) StreamServerInterceptor ¶
func (m *GRPCMetrics) StreamServerInterceptor() grpc.StreamServerInterceptor
func (*GRPCMetrics) UnaryServerInterceptor ¶
func (m *GRPCMetrics) UnaryServerInterceptor() grpc.UnaryServerInterceptor
type GRPCRegistrar ¶
GRPCRegistrar registers service implementations on a gRPC server.
type MetricsContributor ¶
MetricsContributor registers gRPC metrics collectors into a shared registry. Same method signature as github.com/omcrgnt/ops/metrics.MetricsContributor.
type Option ¶ added in v0.26.0
type Option[T GRPCRegistrar] func(*Server[T])
Option configures a Server at construction time, for values ecfg can't fill (e.g. interceptor functions) — see New.
func WithUnaryServerInterceptors ¶ added in v0.26.0
func WithUnaryServerInterceptors[T GRPCRegistrar](in ...grpc.UnaryServerInterceptor) Option[T]
WithUnaryServerInterceptors appends interceptors run in addition to (not instead of) the metrics/gate interceptors this package always installs, in the order given (grpc.ChainUnaryInterceptor semantics: first listed runs outermost).
type Server ¶
type Server[T GRPCRegistrar] struct { // contains filtered or unexported fields }
Server is the gRPC server resource bound to handler type T. Catalog field: *Server[T] (Configurable); materialized *Server[T] is the runtime instance after Config.Build. Runtime methods: Start (returns a cleanup that stops the server), HealthCheck, ProbeReady.
func New ¶ added in v0.26.0
func New[T GRPCRegistrar](opts ...Option[T]) *Server[T]
New constructs a Server[T] with the given options applied. The catalog field holding it must be assigned this (non-nil) in the app's resources literal — left nil (the zero-value default), these options are lost when Build constructs a fresh instance. See client-grpc's Client.New.
func (*Server[T]) BuildConfig ¶
func (t *Server[T]) BuildConfig() (app.Materializer, error)
BuildConfig returns the config spec for materialize, carrying over whatever options New was called with.
func (*Server[T]) DisableGate ¶ added in v0.25.0
func (t *Server[T]) DisableGate()
DisableGate permanently turns off gate-checking for this instance — for servers that must never be traffic-gated (e.g. ops's own readiness endpoint, which would otherwise mask its own status behind a blanket codes.Unavailable, and could false-fail a liveness check sharing the same listener).
Must be called before Start, synchronously by the same caller that wires this Server: Start reads t.gate/t.gateDisabled once, while building the interceptor chain, and never again — a call after Start has already run is a silent no-op, not an error.
func (*Server[T]) ProbeReady ¶
ProbeReady reports traffic readiness (SDI duck typing; no ops import): non-nil if Serve failed after Start (same as HealthCheck), or if a gate is wired, enabled, and not yet open — a caller relying only on HealthCheck would see this Server as ready while every real RPC is still answered Unavailable by the gate interceptor.