server

package
v0.1.0-rc1 Latest Latest
Warning

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

Go to latest
Published: May 9, 2016 License: Apache-2.0 Imports: 30 Imported by: 0

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:

  1. Run
  2. Start
  3. RunWithConfig
  4. StartWithConfig
  5. 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

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

func IsNil(closer io.Closer) bool

IsNil returns a flag indicating whether a server returned by the Serve function is nil.

func NewConfig

func NewConfig(
	host string, tls bool, driversAndServices ...string) gofig.Config

NewConfig returns a confiburation object from basic inputs

func Run

func Run(host string, tls bool, driversAndServices ...string) error

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

func RunWithConfig(config gofig.Config) error

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

func Serve(config gofig.Config) (io.Closer, error, <-chan error)

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, io.Closer, 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

func StartWithConfig(config gofig.Config) (io.Closer, error, <-chan error)

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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