srvgrpc

package module
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: MIT Imports: 15 Imported by: 1 module, 1 package

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 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.

func (*Config[T]) Build

func (cfg *Config[T]) Build() (any, error)

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

type GRPCRegistrar interface {
	RegisterGRPC(*grpc.Server)
}

GRPCRegistrar registers service implementations on a gRPC server.

type MetricsContributor

type MetricsContributor interface {
	RegisterMetrics(reg *prom.Registry) error
}

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]) Deps

func (t *Server[T]) Deps() []any

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]) HealthCheck

func (t *Server[T]) HealthCheck(_ context.Context) error

func (*Server[T]) Inject

func (t *Server[T]) Inject(args []any)

func (*Server[T]) ProbeReady

func (t *Server[T]) ProbeReady(ctx context.Context) error

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.

func (*Server[T]) Start

func (t *Server[T]) Start(ctx context.Context) (func(context.Context) error, error)

Jump to

Keyboard shortcuts

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