golazy.dev golazy.dev / lazycontrolplane Index | Files

package lazycontrolplane

import "golazy.dev/lazycontrolplane"

Package lazycontrolplane provides operational HTTP endpoints for GoLazy applications.

A control plane exposes framework-owned routes such as liveness and readiness probes outside the application's route table. The zero Config is useful: it creates a control plane with /livez and /readyz. Applications can pass Config to lazyapp.Config.ControlPlane to mount those endpoints with the app, or instantiate a ControlPlane directly when they want to serve it manually. Use Config.Pprof or ControlPlane.EnablePprof to attach the standard net/http/pprof handlers.

Types

type Builder

Builder creates a control plane for lazyapp.

Config and *ControlPlane implement Builder. This keeps lazyapp.Config's ControlPlane field optional while still allowing ControlPlane: Config{}.

type Builder interface {
	BuildControlPlane() *ControlPlane
}

type ControlPlane

ControlPlane routes operational endpoints.

type ControlPlane struct {
	// contains filtered or unexported fields
}
func New

New builds a control plane from config.

func New(config Config) *ControlPlane
func (plane *ControlPlane) AddReadinessCheck

AddReadinessCheck appends a readiness check to /readyz.

func (plane *ControlPlane) AddReadinessCheck(check ReadinessCheck)
func (plane *ControlPlane) BuildControlPlane

BuildControlPlane implements Builder.

func (plane *ControlPlane) BuildControlPlane() *ControlPlane
func (plane *ControlPlane) EnablePprof

EnablePprof registers the standard net/http/pprof handlers.

It is safe to call EnablePprof more than once.

func (plane *ControlPlane) EnablePprof()
func (plane *ControlPlane) Handle

Handle registers an exact control-plane endpoint.

func (plane *ControlPlane) Handle(pattern string, handler http.Handler)
func (plane *ControlPlane) Handler

Handler mounts the control plane in front of next.

func (plane *ControlPlane) Handler(next http.Handler) http.Handler
func (plane *ControlPlane) HandlesPath

HandlesPath reports whether path belongs to the control plane.

func (plane *ControlPlane) HandlesPath(path string) bool
func (plane *ControlPlane) ServeHTTP

ServeHTTP serves control-plane endpoints.

func (plane *ControlPlane) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (plane *ControlPlane) StandaloneHandler

StandaloneHandler serves the control plane on its own listener.

It adds a root HTML index that lists registered endpoints. Use Handler when the control plane shares an application listener so "/" stays owned by the app.

func (plane *ControlPlane) StandaloneHandler() http.Handler