server

package
v0.0.0-...-5818010 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Env

func Env(env string) func(o *Opts)

Env ...

func Name

func Name(name string) func(o *Opts)

Name ...

func WithPprof

func WithPprof() func(o *DebugOpts)

WithPprof ...

func WithPrometheusHandler

func WithPrometheusHandler(handler http.Handler) func(o *DebugOpts)

WithPrometheusHandler is adding this prometheus http handler as an option.

func WithStatusAddr

func WithStatusAddr(addr string) func(o *DebugOpts)

WithStatusAddr is adding this status addr as an option.

Types

type DebugOpt

type DebugOpt func(*DebugOpts)

DebugOpt ...

type DebugOpts

type DebugOpts struct {
	Addr string

	Routes map[string]http.Handler
}

DebugOpts ...

type Listener

type Listener interface {
	// Start is being called on the listener
	Start(ctx context.Context, ready func()) func() error
}

Listener is the interface to a listener, so starting and shutdown of a listener, or any routine.

func NewDebugListener

func NewDebugListener(opts ...DebugOpt) Listener

NewDebugListener ...

type Opt

type Opt func(*Opts)

Opt ...

type Opts

type Opts struct {
	// Name
	Name string
	// Env
	Env string
	// ReloadSignal
	ReloadSignal syscall.Signal
	// TermSignal
	TermSignal syscall.Signal
	// KillSignal
	KillSignal syscall.Signal
}

Opts ...

type Server

type Server interface {
	// Run is running a new routine
	Listen(listener Listener, ready bool)
	// Name
	Name() string
	// Env
	Env() string
	// Waits for the server to fail,
	// or gracefully shutdown if called
	Wait() error
}

Server is the interface to be implemented to run the server.

s, ctx := WithContext(context.Background())
s.Listen(listener, false)

if err := s.Wait(); err != nil {
	panic(err)
}

func WithContext

func WithContext(ctx context.Context, opts ...Opt) (Server, context.Context)

WithContext ...

Jump to

Keyboard shortcuts

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