server

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultGracePeriod = 5 * time.Second

DefaultGracePeriod is the default value of the duration gracefully shuts down the server without interrupting any active connections.

View Source
const DefaultReadTimeout = 2 * time.Minute

DefaultReadTimeout is the default value of the maximum duration for reading the entire request, including the body.

View Source
const DefaultRequestTimeout = 2 * time.Minute

DefaultRequestTimeout is the default value of the timeout duration per request.

View Source
const DefaultWriteTimeout = 2 * time.Minute

DefaultWriteTimeout is the default value of the maximum duration before timing out writes of the response.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

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

Option overrides behavior of Server.

func WithGracePeriod

func WithGracePeriod(t time.Duration) Option

WithGracePeriod sets graceful shutdown period for the server.

func WithListen

func WithListen(s string) Option

WithListen sets the port to listen for the server.

func WithMetricReadEndpoint

func WithMetricReadEndpoint(u *url.URL) Option

WithMetricReadEndpoint sets the URL to proxy metrics read request to.

func WithMetricUIEndpoint

func WithMetricUIEndpoint(u *url.URL) Option

WithMetricUIEndpoint TODO

func WithMetricWriteEndpoint

func WithMetricWriteEndpoint(u *url.URL) Option

WithMetricWriteEndpoint sets the URL to proxy metrics write request to.

func WithProfile

func WithProfile(p bool) Option

WithProfile sets the option to enable/disable profiler endpoint.

func WithProxyOptions

func WithProxyOptions(opts ...proxy.Option) Option

WithProxyOptions sets the proxy options fot the underlying reverse proxy.

func WithReadTimeout

func WithReadTimeout(t time.Duration) Option

WithReadTimeout sets the read timeout duration for the underlying HTTP server.

func WithRequestTimeout

func WithRequestTimeout(t time.Duration) Option

WithRequestTimeout sets the timeout duration for an individual request.

func WithTLSConfig

func WithTLSConfig(c *tls.Config) Option

WithTLSConfig TODO

func WithWriteTimeout

func WithWriteTimeout(t time.Duration) Option

WithWriteTimeout sets the write timeout duration for the underlying HTTP server.

type Server

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

Server defines parameters for running an HTTP server.

func New

func New(logger log.Logger, reg *prometheus.Registry, opts ...Option) Server

New creates a new Server.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

ListenAndServe listens on the TCP network address and handles connections with given server configuration.

func (*Server) Shutdown

func (s *Server) Shutdown(err error)

Shutdown gracefully shuts down the server.

Jump to

Keyboard shortcuts

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