server

package
v0.0.0-...-46fa93d Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: BSD-3-Clause Imports: 21 Imported by: 1

Documentation

Overview

Package server provides a generic server implementation which is used by the different applications to serve their build info, health status and API.

Index

Constants

View Source
const (
	BuildInfoRoute         = buildinfo.MetricName
	HealthCheckRoute       = "healthcheck"
	PrometheusMetricsRoute = "prometheus-metrics"

	ErrInvalidPrometheusPath errors.Msg = "invalid prometheus path"
	ConfigValidationError               = youlessclient.ConfigValidationError
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Port      serv.Port `default:"2512"`
	AccessLog bool      `default:"true"`
	TLS       serv.TLSConfig
}

func (Config) Validate

func (c Config) Validate() error

type Option

type Option interface {
	// contains filtered or unexported methods
}

func With

func With(fn func(app *Server) Option) Option

func WithBuildInfo

func WithBuildInfo(bld *buildinfo.BuildInfo) Option

func WithRoutes

func WithRoutes(r serv.RoutesRegisterer) Option

func WithTelemetry

func WithTelemetry(tc telemetry.Config) Option

func WithTelemetryAndPrometheus

func WithTelemetryAndPrometheus(tc telemetry.Config, pc PrometheusConfig) Option

type PrometheusConfig

type PrometheusConfig struct {
	Enabled bool
	Path    string `default:"/metrics"`
}

func (PrometheusConfig) Validate

func (c PrometheusConfig) Validate() error

type Server

type Server struct {
	// contains filtered or unexported fields
}

func New

func New(name string, conf Config, log zerolog.Logger, handler http.Handler, opts ...Option) (*Server, error)

func (*Server) MeterProvider

func (app *Server) MeterProvider() telemetry.MeterProvider

func (*Server) Name

func (app *Server) Name() string

func (*Server) Router

func (app *Server) Router() serv.Router

func (*Server) Run

func (app *Server) Run(ctx context.Context) error

func (*Server) Shutdown

func (app *Server) Shutdown(ctx context.Context) error

func (*Server) TracerProvider

func (app *Server) TracerProvider() telemetry.TracerProvider

Jump to

Keyboard shortcuts

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