server

package
v2.10.1 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: MIT Imports: 17 Imported by: 1

Documentation

Overview

Package server provides a generic HTTP server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GenericServer

type GenericServer[T context.Context] struct {
	Addr              string
	TLSConfig         *tls.Config
	Handler           http.Handler
	ReadHeaderTimeout time.Duration
	ReadTimeout       time.Duration
	WriteTimeout      time.Duration
	IdleTimeout       time.Duration
	ShutdownTimeout   time.Duration

	Stats *statter.Statter
	Log   *logger.Logger
	// contains filtered or unexported fields
}

GenericServer is an HTTP server.

The server handles `/livez` and `/readyz` endpoints as well as post-start and pre-shutdown hooks.

func (*GenericServer[T]) AddHealthzChecks

func (s *GenericServer[T]) AddHealthzChecks(checks ...healthz.HealthChecker) error

AddHealthzChecks adds health checks to both readyz and livez.

func (*GenericServer[T]) AddLivezChecks

func (s *GenericServer[T]) AddLivezChecks(checks ...healthz.HealthChecker) error

AddLivezChecks adds health checks to livez.

func (*GenericServer[T]) AddPostStartHook

func (s *GenericServer[T]) AddPostStartHook(name string, fn PostStartHookFunc[T]) error

AddPostStartHook adds a post-start hook.

func (*GenericServer[T]) AddPreShutdownHook

func (s *GenericServer[T]) AddPreShutdownHook(name string, fn PreShutdownHookFunc) error

AddPreShutdownHook adds a pre-shutdown hook.

func (*GenericServer[T]) AddReadyzChecks

func (s *GenericServer[T]) AddReadyzChecks(checks ...healthz.HealthChecker) error

AddReadyzChecks adds health checks to readyz.

func (*GenericServer[T]) MustAddHealthzChecks

func (s *GenericServer[T]) MustAddHealthzChecks(checks ...healthz.HealthChecker)

MustAddHealthzChecks adds health checks to both readyz and livez, panicking if there is an error.

func (*GenericServer[T]) MustAddLivezChecks

func (s *GenericServer[T]) MustAddLivezChecks(checks ...healthz.HealthChecker)

MustAddLivezChecks adds health checks to livez, panicking if there is an error.

func (*GenericServer[T]) MustAddPostStartHook

func (s *GenericServer[T]) MustAddPostStartHook(name string, fn PostStartHookFunc[T])

MustAddPostStartHook adds a post-start hook, panicking if there is an error.

func (*GenericServer[T]) MustAddPreShutdownHook

func (s *GenericServer[T]) MustAddPreShutdownHook(name string, fn PreShutdownHookFunc)

MustAddPreShutdownHook adds a pre-shutdown hook, panicking if there is an error.

func (*GenericServer[T]) MustAddReadyzChecks

func (s *GenericServer[T]) MustAddReadyzChecks(checks ...healthz.HealthChecker)

MustAddReadyzChecks adds health checks to readyz, panicking if there is an error.

func (*GenericServer[T]) Run

func (s *GenericServer[T]) Run(ctx T) error

Run runs the server, managing the full server lifecycle.

If the server fails to start, e.g. bind error, no hooks are run. This function is blocking.

type PostStartHookFunc

type PostStartHookFunc[T context.Context] func(T) error

PostStartHookFunc is a function called after server start.

type PreShutdownHookFunc

type PreShutdownHookFunc func() error

PreShutdownHookFunc is a function called before server shutdown.

Jump to

Keyboard shortcuts

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