Categorygithub.com/chapsuk/mserv
modulepackage
1.1.1
Repository: https://github.com/chapsuk/mserv.git
Documentation: pkg.go.dev

# README

Mserv

Build Status FOSSA Status

Package for grouping many servers (http, grpc, ...) and start|stop by single command. Aims to simplify startup process and controll group of servers.

Example

Start 3 http servers: pprof, prometheus, api.

// set  skipErros option for not critical component
srv1 := mserv.NewHTTPServer(&http.Server{Addr: "8080", http.DefaultServeMux}, mserv.HTTPSkipErrors(true))
srv2 := mserv.NewHTTPServer(&http.Server{Addr: "8081", promhttp.Handler()})
// set shutdown timeout
srv3 := mserv.NewHTTPServer(&http.Server{Addr: "8082", api()}, mserv.HTTPShutdownTimeout(5*time.Second))

// the servers order is keeped at startup
srvs := mserv.New(srv1, srv2, srv3)
err  := srvs.Start()
// ... do work ...
err := srvs.Stop()

# Functions

HTTPShutdownTimeout sets shutdown timeout.
HTTPSkipErrors sets skip errors flag.
HTTPWithTLSConfig define tls config for server.
New returns new multiple servers instance, skip nil servers.
NewHTTPServer returns new http.Server wrapper.

# Structs

HTTPServer wrapper of http.Server.
MultiServer is servers aggregator.

# Interfaces

Server interface.

# Type aliases

HTTPServerOption allows configure http server optional settings.