serverz

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2017 License: MIT Imports: 5 Imported by: 1

README

Serverz

Build Status Go Report Card GoDoc

Web app toolkit to easily manage server based environments.

Documentation

Development

You need Glide to install dependencies.

$ make install

Run tests and linters:

$ make check

License

The MIT License (MIT). Please see License File for more information.

Documentation

Overview

Package serverz is a web app toolkit to easily manage server based environments

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GrpcServer added in v0.2.0

type GrpcServer struct {
	*grpc.Server
}

GrpcServer implements the Server interface for a gRPC server

func (*GrpcServer) Close added in v0.2.0

func (s *GrpcServer) Close() error

Close implements Server

func (*GrpcServer) Shutdown added in v0.2.0

func (s *GrpcServer) Shutdown(ctx context.Context) error

Shutdown implements Server interface

type NamedServer

type NamedServer struct {
	Server Server
	Name   string
}

NamedServer can be used to parametrize logs

func (*NamedServer) Close

func (ns *NamedServer) Close() error

Close implements Server

func (*NamedServer) Serve

func (ns *NamedServer) Serve(l net.Listener) error

Serve implements Server interface

func (*NamedServer) Shutdown

func (ns *NamedServer) Shutdown(ctx context.Context) error

Shutdown implements Server interface

type Server

type Server interface {
	// Serve accepts incoming connections on the Listener l.
	//
	// Serve always returns a non-nil error.
	Serve(l net.Listener) error

	// Shutdown gracefully shuts down the server without interrupting any
	// active connections. Shutdown works by first closing all open
	// listeners, then closing all idle connections, and then waiting
	// indefinitely for connections to return to idle and then shut down.
	// If the provided context expires before the shutdown is complete,
	// then the context's error is returned.
	Shutdown(ctx context.Context) error

	// Close immediately closes all active net.Listeners.
	//
	// For a graceful shutdown, use Shutdown.
	Close() error
}

Server in this context is an abstraction over anything that can be started and stopped (either gracefully or forcefully) Typically they accept connections and serve over network, like HTTP or RPC servers

type ServerManager

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

ServerManager manages multiple Servers' lifecycle

func NewServerManager

func NewServerManager(logger logrus.FieldLogger) *ServerManager

NewServerManager creates a new ServerManager

func (*ServerManager) ListenAndStartServer

func (sm *ServerManager) ListenAndStartServer(server Server, addr string) func(ch chan<- error)

ListenAndStartServer creates a server starter function which listens on a port and can be called as a goroutine

func (*ServerManager) StartServer

func (sm *ServerManager) StartServer(server Server, listener net.Listener) func(ch chan<- error)

StartServer creates a server starter function which can be called as a goroutine

func (*ServerManager) StopServer

func (sm *ServerManager) StopServer(server Server, wg *sync.WaitGroup) func(ctx context.Context)

StopServer creates a server stopper function which can be called as a goroutine

Jump to

Keyboard shortcuts

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