server

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: AGPL-3.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	HTTPListenAddress string `yaml:"http_listen_address"`
	// HTTPListenPort specifies the port to listen on. If the port is 0, a port
	// number is automatically chosen. The Addr method of Server can be used to
	// discover the chosen port. The value in Config will not be updated.
	HTTPListenPort int `yaml:"http_listen_port"`
	HTTPConnLimit  int `yaml:"http_conn_limit"`

	ServerGracefulShutdownTimeout time.Duration `yaml:"server_graceful_shutdown_timeout"`
	HTTPServerReadTimeout         time.Duration `yaml:"http_server_read_timeout"`
	HTTPServerWriteTimeout        time.Duration `yaml:"http_server_write_timeout"`
	HTTPServerIdleTimeout         time.Duration `yaml:"http_server_idle_timeout"`

	HTTPMaxRequestSizeLimit int64 `yaml:"http_max_request_size_limit"`

	GRPCListenPort int `yaml:"grpc_listen_port"`

	PathPrefix string `yaml:"path_prefix"`
}

func (*Config) RegisterFlags

func (cfg *Config) RegisterFlags(flags *flag.FlagSet)

RegisterFlags adds the flags required to config this to the given FlagSet

func (*Config) RegisterFlagsWithPrefix

func (cfg *Config) RegisterFlagsWithPrefix(prefix string, flags *flag.FlagSet)

RegisterFlagsWithPrefix registers flags, adding the provided prefix if needed. If the prefix is not blank and doesn't end with '.', a '.' is appended to it.

type Server

type Server struct {
	Router     *mux.Router
	HTTPServer *http.Server
	GRPCServer *grpc.Server
	// contains filtered or unexported fields
}

Server initializes an Router webserver as well as the desired middleware configuration

func NewServer

func NewServer(log log.Logger, cfg Config, router *mux.Router, middlewares []middleware.Interface) (*Server, error)

NewServer initializes an httpserver with a router and all the configuration parameters given. Note that all the provided middlewares are wrapped in order.

func (*Server) Addr

func (s *Server) Addr() net.Addr

Addr returns the address the server is listening on.

func (*Server) Handler

func (s *Server) Handler() (run func() error, stop func(error))

Handler returns two functions to run and stop the server.

func (*Server) Run

func (s *Server) Run() error

func (*Server) Shutdown

func (s *Server) Shutdown(_ error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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