stdlogical

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package stdlogical contains a template for building a standard logical-replication CLI command.

Index

Constants

View Source
const MetricsAddrFlag = "metricsAddr"

MetricsAddrFlag is a global flag that will start an HTTP server.

Variables

This section is empty.

Functions

func AddHandlers

func AddHandlers(auth types.Authenticator, mux *http.ServeMux, diags *diag.Diagnostics)

AddHandlers populates the ServeMux with diagnostic endpoints.

func MetricsServer

func MetricsServer(
	auth types.Authenticator, bindAddr string, diags *diag.Diagnostics,
) (func(), error)

MetricsServer starts a trivial HTTP server which runs until canceled.

func New

func New(t *Template) *cobra.Command

New constructs a standard logical-replication command.

Types

type Config

type Config interface {
	Bind(set *pflag.FlagSet)
}

Config is our standard protocol for configuration objects.

type HasAuthenticator

type HasAuthenticator interface {
	GetAuthenticator() types.Authenticator
}

HasAuthenticator allows the object to supply a types.Authenticator.

type HasDiagnostics

type HasDiagnostics interface {
	GetDiagnostics() *diag.Diagnostics
}

HasDiagnostics allows the object to supply a diag.Diagnostics.

type HasServeMux

type HasServeMux interface {
	GetServeMux() *http.ServeMux
}

HasServeMux allows the object to provide a http.ServeMux to bind the endpoints to, if the MetricsAddrFlag is not set.

type Template

type Template struct {
	// An optional object for CLI flag registration.
	Config Config
	// An optional default value for [MetricsAddrFlag].
	Metrics string
	// Passed to [cobra.Command.Short].
	Short string
	// Start should return an object that implements zero or more of the
	// capability interfaces in this package.
	Start func(ctx *stopper.Context, cmd *cobra.Command) (started any, err error)
	// Passed to [cobra.Command.Use].
	Use string
	// contains filtered or unexported fields
}

A Template contains the input for New.

Jump to

Keyboard shortcuts

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