web

package
v0.13.6 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2020 License: MIT Imports: 14 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// ErrEmptyGRPCServer is raised when called NewGRPCService
	// or gRPC methods with empty grpc.Server.
	ErrEmptyGRPCServer = internal.Error("empty gRPC server")

	// ErrEmptyGRPCAddress is raised when passed empty address to NewGRPCService.
	ErrEmptyGRPCAddress = internal.Error("empty gRPC address")
)
View Source
const (
	// ErrEmptyHTTPServer is raised when called New
	// or httpService methods with empty http.Server.
	ErrEmptyHTTPServer = internal.Error("empty http server")

	// ErrEmptyHTTPAddress is raised when passed empty address to NewHTTPService.
	ErrEmptyHTTPAddress = internal.Error("empty http address")
)
View Source
const (
	// ErrEmptyLogger is raised when empty logger passed into New function.
	ErrEmptyLogger = internal.Error("empty logger")

	// ErrEmptyServices is raised when empty services passed into New function.
	ErrEmptyServices = internal.Error("empty services")
)
View Source
const ErrEmptyListener = internal.Error("empty listener")

ErrEmptyListener is raised when an empty Listener used in the NewListener function or Listener methods.

Variables

View Source
var (
	// ServersModule of web base structs
	ServersModule = module.Module{
		{Constructor: newDefaultGRPCServer},
		{Constructor: newProfileServer},
		{Constructor: newMetricServer},
		{Constructor: NewAPIServer},
		{Constructor: NewMultiServer},
	}
)

Functions

This section is empty.

Types

type APIParams added in v0.5.0

type APIParams struct {
	dig.In

	Config  *viper.Viper
	Logger  *zap.Logger
	Handler http.Handler `optional:"true"`
}

APIParams struct

type GRPCOption added in v0.13.0

type GRPCOption func(g *gRPC)

GRPCOption allows changing default gRPC service settings.

func GRPCListenAddress added in v0.13.0

func GRPCListenAddress(addr string) GRPCOption

GRPCListenAddress allows to change network for net.Listener.

func GRPCListenNetwork added in v0.13.0

func GRPCListenNetwork(network string) GRPCOption

GRPCListenNetwork allows to change default (tcp) network for net.Listener.

func GRPCShutdownTimeout added in v0.13.0

func GRPCShutdownTimeout(v time.Duration) GRPCOption

GRPCShutdownTimeout changes default shutdown timeout.

func GRPCSkipErrors added in v0.13.0

func GRPCSkipErrors() GRPCOption

GRPCSkipErrors allows to skip any errors

type HTTPOption added in v0.13.0

type HTTPOption func(s *httpService)

HTTPOption interface that allows to change default http-service options.

func HTTPListenAddress added in v0.13.0

func HTTPListenAddress(address string) HTTPOption

HTTPListenAddress allows to change network for net.Listener. By default it takes address from http.Server.

func HTTPListenNetwork added in v0.13.0

func HTTPListenNetwork(network string) HTTPOption

HTTPListenNetwork allows to change default (tcp) network for net.Listener.

func HTTPShutdownTimeout added in v0.13.0

func HTTPShutdownTimeout(v time.Duration) HTTPOption

HTTPShutdownTimeout changes default shutdown timeout.

func HTTPSkipErrors added in v0.13.0

func HTTPSkipErrors() HTTPOption

HTTPSkipErrors allows to skip any errors

type Listener added in v0.13.0

type Listener interface {
	ListenAndServe() error
	Shutdown(context.Context) error
}

Listener service interface.

type ListenerOption added in v0.13.0

type ListenerOption func(l *listener)

ListenerOption options that allows to change default settings for Listener service.

func ListenerIgnoreError added in v0.13.0

func ListenerIgnoreError(errors ...error) ListenerOption

ListenerIgnoreError allows for ignoring all passed errors.

func ListenerShutdownTimeout added in v0.13.0

func ListenerShutdownTimeout(v time.Duration) ListenerOption

ListenerShutdownTimeout allows changing the default shutdown timeout.

func ListenerSkipErrors added in v0.13.0

func ListenerSkipErrors() ListenerOption

ListenerSkipErrors allows for ignoring all raised errors.

type MultiServerParams added in v0.5.0

type MultiServerParams struct {
	dig.In

	Logger  *zap.Logger
	Servers []Service `group:"services"`
}

MultiServerParams struct

type ServerResult added in v0.5.0

type ServerResult struct {
	dig.Out

	Server Service `group:"services"`
}

ServerResult struct

func NewAPIServer added in v0.5.0

func NewAPIServer(p APIParams) (ServerResult, error)

NewAPIServer creates api server by http.Handler from DI container

func NewGRPCServer added in v0.13.4

func NewGRPCServer(v *viper.Viper, key string, s *grpc.Server, l *zap.Logger) (ServerResult, error)

NewGRPCServer creates gRPC server that will be embedded info multi-server.

func NewHTTPServer added in v0.11.10

func NewHTTPServer(v *viper.Viper, key string, h http.Handler, l *zap.Logger) (ServerResult, error)

NewHTTPServer creates http-server that will be embedded into multi-server

type Service added in v0.13.0

type Service interface {
	Start() error
	Stop() error
}

Service interface that allows start and stop

func New added in v0.13.0

func New(log *zap.Logger, services ...Service) (Service, error)

New gets logger and services to create multiple service runner.

func NewGRPCService added in v0.13.0

func NewGRPCService(serve *grpc.Server, opts ...GRPCOption) (Service, error)

NewGRPCService creates gRPC service with passed gRPC options. If something went wrong it returns an error.

func NewHTTPService added in v0.13.0

func NewHTTPService(serve *http.Server, opts ...HTTPOption) (Service, error)

NewHTTPService creates Service from http.Server and HTTPOption's.

func NewListener added in v0.13.0

func NewListener(lis Listener, opts ...ListenerOption) (Service, error)

NewListener creates new Listener service and applies passed options to it.

func NewMultiServer added in v0.5.0

func NewMultiServer(p MultiServerParams) (Service, error)

NewMultiServer returns new multi servers group

Jump to

Keyboard shortcuts

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