server

package
v0.0.0-...-f9509b0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// BindAddress that the server binds to
	BindAddress string `yaml:"bind_address"`

	// GracefulTimeout duration for which the server gracefully wait for
	// existing connections to finish before exiting.
	GracefulTimeout time.Duration `yaml:"graceful_timeout"`

	// RateLimit specifies requests per second and burst with the format
	// '<reqs/sec>:<burst>'. Empty string means no limit.
	RateLimit string `yaml:"rate_limit"`
}

Config struct for configuring a Server.

func (*Config) Validate

func (c *Config) Validate() error

Validate a Config.

type Option

type Option func(*serverConfig)

func WithIgnoreLoggingRequest

func WithIgnoreLoggingRequest(f func(*http.Request) bool) Option

func WithMetricSink

func WithMetricSink(metricSink metrics.MetricSink) Option

type Server

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

Server struct for an HTTP server.

func NewServer

func NewServer(log *zap.Logger, config Config, router *muxt.Router, opts ...Option) *Server

NewServer creates a new Server.

func (*Server) Run

func (s *Server) Run(errs chan error) func()

Run starts the server in a goroutine, and any errors returned by the server at shutdown time will be passed to the provided chan parameter. Run returns a shutdown callback that will safely stop the server when called.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳