serve

package
v0.10.174 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

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...),
	)
}

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 blocks until ctx is cancelled or the server fails. 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

func WithMetricsPort(port int) Option

WithMetricsPort sets the Prometheus metrics listen port. Defaults to 2112.

func WithPort

func WithPort(port int) Option

WithPort sets the gRPC listen port. Defaults to 8080, matching the PORT convention Cloud Run uses.

func WithPprof

func WithPprof(enabled bool) Option

WithPprof exposes pprof handlers on the metrics listener.

Jump to

Keyboard shortcuts

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