serverpub

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnhealthy is returned when a server is considered unhealthy.
	ErrUnhealthy = errors.New("Service is unhealthy")
)

Functions

This section is empty.

Types

type HealthPinger

type HealthPinger interface {
	Ping() error
}

HealthPinger exposes what we expect to provide us a Health check for a server.

type HttpHealthIndicator

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

func (*HttpHealthIndicator) Ping

func (h *HttpHealthIndicator) Ping() error

Ping implements the HealthPinger interface.

func (*HttpHealthIndicator) SetHealthy

func (h *HttpHealthIndicator) SetHealthy()

func (*HttpHealthIndicator) SetUnhealthy

func (h *HttpHealthIndicator) SetUnhealthy()

type Server

type Server struct {
	Http2           bool
	ShutdownTimeout time.Duration
	Handler         http.Handler
	ReadyFunc       func()
	Health          *HttpHealthIndicator
	TLSConfig       *tls.Config
	Man             *autocert.Manager
	// contains filtered or unexported fields
}

Server implements a http server wrapper.

func NewServer

func NewServer(handler http.Handler, shutdown ...time.Duration) *Server

NewServer returns a new server which uses http instead of https.

func NewServerWithCertMan

func NewServerWithCertMan(http2 bool, man *autocert.Manager, handler http.Handler, shutdown ...time.Duration) *Server

NewServerWithCertMan returns a new server which uses the provided autocert certificate manager to provide http certificate.

func NewServerWithTLS

func NewServerWithTLS(http2 bool, tconfig *tls.Config, handler http.Handler, shutdown ...time.Duration) *Server

NewServerWithTLS returns a new server which uses the provided tlsconfig for https connections.

func (*Server) Close

func (s *Server) Close()

Close closes giving server

func (*Server) Listen

func (s *Server) Listen(ctx context.Context, addr string) error

Listen creates new http listen for giving addr and returns any error that occurs in attempt to starting the server.

func (*Server) TLSManager

func (s *Server) TLSManager() *autocert.Manager

TLSManager returns the autocert.Manager associated with the giving server for its tls certificates.

func (*Server) Wait

func (s *Server) Wait(after ...func())

Wait blocks till server is closed.

Jump to

Keyboard shortcuts

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