Documentation
¶
Overview ¶
Package serve runs a workqueue.WorkqueueServiceServer on the standard duplex gRPC server: trace-parent restoration, OpenTelemetry stats, metrics and recovery interceptors, a gRPC health service, and the metrics listener. It is the serving half of githubreconciler.Main, available to reconcilers that assemble their own server (Linear, OCI, APK, or dual-key wrappers) without re-copying the wiring.
Configuration is passed as options. Reading the environment is the caller's job, conventionally in a main package via envconfig.
Example ¶
Example shows the shape of a main that assembles its own workqueue server. Environment parsing, credentials, and reconciler construction stay in the caller; ListenAndServe only owns the gRPC plumbing.
package main
import (
"context"
"chainguard.dev/driftlessaf/workqueue"
"chainguard.dev/driftlessaf/workqueue/serve"
"google.golang.org/grpc"
)
func main() {
var (
ctx context.Context
srv workqueue.WorkqueueServiceServer // e.g. from linearreconciler.New
port int // from envconfig
interceptors []grpc.UnaryServerInterceptor
)
_ = serve.ListenAndServe(ctx, srv,
serve.WithPort(port),
serve.WithInterceptors(interceptors...),
)
}
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ListenAndServe ¶
func ListenAndServe(ctx context.Context, srv workqueue.WorkqueueServiceServer, opts ...Option) error
ListenAndServe registers srv and a health service on a duplex gRPC server, starts the metrics listener and memusage.Heartbeat, and blocks until ctx is cancelled or the server fails. On cancellation it drains in-flight requests for up to shutdownGrace and returns nil. The metrics listener and the memory heartbeat run for the life of the process, not of the call, so a second call with the same metrics port in one process exits the process. Callers set up profiling, metrics, and tracing exporters before calling it, as githubreconciler.Main does.
Types ¶
type Option ¶
type Option func(*options)
Option configures ListenAndServe.
func WithInterceptors ¶
func WithInterceptors(inter ...grpc.UnaryServerInterceptor) Option
WithInterceptors adds gRPC unary server interceptors that run before the default metrics and recovery interceptors.
func WithMetricsPort ¶
WithMetricsPort sets the Prometheus metrics listen port. Defaults to 2112.