Documentation ¶
Overview ¶
Package server is the homeo of the reference implementation of the libStorage API server. There are five functions that will start a server instance:
- Run
- Start
- RunWithConfig
- StartWithConfig
- Serve
The Run functions start a server and block until a signal is received by the owner process. The Start functions will start a server and return a channel on which any server errors are returned. This channel can be used to block or ignored to start a server asynchronously.
The Serve function is ultimately what the above functions invoke, but with an important distinction. The above functions 1-4 all track the servers that are started inside a single process and upon the process's abrupt termination will enable the graceful shutdown of all running/started server instances. However, the Server function is the low-level method for creating and running a server, and it's up to the end-user to do any type of resource tracking in order to enable graceful shutdowns if that method is used directly.
Index ¶
- func Close() <-chan error
- func CloseOnAbort()
- func IsNil(closer io.Closer) bool
- func NewConfig(host string, tls bool, driversAndServices ...string) gofig.Config
- func Run(host string, tls bool, driversAndServices ...string) error
- func RunWithConfig(config gofig.Config) error
- func Serve(config gofig.Config) (types.Server, error, <-chan error)
- func Start(host string, tls bool, driversAndServices ...string) (gofig.Config, types.Server, error, <-chan error)
- func StartWithConfig(config gofig.Config) (types.Server, error, <-chan error)
- type HTTPServer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Close ¶
func Close() <-chan error
Close closes all servers. This function can be used when a calling program traps UNIX signals or when it exits gracefully.
func CloseOnAbort ¶
func CloseOnAbort()
CloseOnAbort is a helper function that can be called by programs, such as tests or a command line or service application.
func IsNil ¶
IsNil returns a flag indicating whether a server returned by the Serve function is nil.
func Run ¶
Run runs the server and blocks until a Kill signal is received by the owner process or the server returns an error via its error channel.
func RunWithConfig ¶
RunWithConfig runs the server by specifying a configuration object and blocks until a Kill signal is received by the owner process or the server returns an error via its error channel.
func Serve ¶
Serve starts serving the configured libStorage endpoints. This function returns a channel on which errors are received. Reading this channel is also the prescribed manner for clients wishing to block until the server is shutdown as the error channel will be closed when the server is stopped.
func Start ¶
func Start(host string, tls bool, driversAndServices ...string) ( gofig.Config, types.Server, error, <-chan error)
Start starts the server and returns a channel when errors occur runs until a Kill signal is received by the owner process or the server returns an error via its error channel.
func StartWithConfig ¶
StartWithConfig starts the server by specifying a configuration object and returns a channel when errors occur runs until a Kill signal is received by the owner process or the server returns an error via its error channel.
Types ¶
type HTTPServer ¶
type HTTPServer struct {
// contains filtered or unexported fields
}
HTTPServer contains an instance of http server and the listener.
srv *http.Server, contains configuration to create a http server and a mux router with all api end points.
l net.Listener, is a TCP or Socket listener that dispatches incoming request to the router.
func (*HTTPServer) Close ¶
func (s *HTTPServer) Close() error
Close closes the HTTPServer from listening for the inbound requests.
func (*HTTPServer) Context ¶
func (s *HTTPServer) Context() types.Context
Context returns this server's types.
func (*HTTPServer) Serve ¶
func (s *HTTPServer) Serve() error
Serve starts listening for inbound requests.