server

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

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

Config implements a server config.

func NewConfig added in v0.7.0

func NewConfig(ctors ConfigConstructors, opts ...config.Option) (*Config, error)

NewConfig returns a new configuration for a server built with the given constructors.

func (*Config) DB added in v0.7.0

func (cfg *Config) DB() sql.Config

func (*Config) GRPCServer added in v0.7.0

func (cfg *Config) GRPCServer() grpc.Config

func (*Config) HTTPServer added in v0.7.0

func (cfg *Config) HTTPServer() http.Config

func (*Config) Logger added in v0.7.0

func (cfg *Config) Logger() log.Config

type ConfigConstructors added in v0.7.0

type ConfigConstructors struct {
	// NewLogger is used to creates a new logger config.
	NewLoggerConfig func(...config.Option) (log.Config, error)

	// NewDB is used to creates a new db config.
	NewDBConfig func(...config.Option) (sql.Config, error)

	// NewGRPCServer is used to create a new gRPC server config.
	NewGRPCServerConfig func(...config.Option) (grpc.Config, error)

	// NewHTTPServer is used to create a new HTTP server config.
	NewHTTPServerConfig func(...config.Option) (http.Config, error)
}

ConfigConstructors injects a set of constructors to be used when creating a new server config.

type Errors added in v0.7.0

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

func NewErrors added in v0.7.0

func NewErrors(errs ...error) Errors

func (Errors) Error added in v0.7.0

func (e Errors) Error() string

type GRPCServer added in v0.7.0

type GRPCServer interface {
	// Serve is the entry point for a service and will be run it a goroutine.
	// It is passed a channel to communicate the result.
	Serve(result chan<- error)

	// Stop stops the server.
	Stop()

	// Registers the given services with this server.
	Register([]grpc.Service)
}

GRPCServer abstracts a gRPC server.

type HTTPServer added in v0.7.0

type HTTPServer interface {
	// Serve is the entry point for a service and will be run it a goroutine.
	// It is passed a channel to communicate the result.
	Serve(result chan<- error)

	// Stop stops the server.
	Stop()

	// Handle associates the given handler with the server.
	Handle(mux nethttp.Handler)
}

type Server

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

Server is a combination grpc and http server.

func New added in v0.7.0

NewServer returns a combinator grpc and http server.

func (*Server) DB added in v0.7.0

func (s *Server) DB() sql.DB

func (*Server) Handle added in v0.7.0

func (s *Server) Handle(mux nethttp.Handler)

func (*Server) Register added in v0.7.0

func (s *Server) Register(services []grpc.Service)

func (*Server) Serve

func (s *Server) Serve(ctx context.Context) error

Serve starts the server and will catch os signals. If an os signal is caught, the server will be cancelled via it's the context.

func (*Server) Stop

func (s *Server) Stop()

type ServerConstructors added in v0.7.0

type ServerConstructors struct {
	// NewConfig is used to create a new server config.
	NewConfig func(...config.Option) (*Config, error)

	// NewLogger is used to create a new logger.
	NewLogger func(log.Config) log.Logger

	// NewDB is used to create a new DB.
	NewDB func(sql.Config, ...sql.Option) (sql.DB, error)

	// NewGRPCServer is used to create a new gRPC server.
	NewGRPCServer func(grpc.Config, ...grpc.Option) (GRPCServer, error)

	// NewHTTPServer is used to create a new HTTP server.
	NewHTTPServer func(http.Config, ...http.Option) (HTTPServer, error)
}

ServerConstructors injects a set of constructors to be used when creating a new server.

Directories

Path Synopsis
Package mockserver is a generated GoMock package.
Package mockserver is a generated GoMock package.

Jump to

Keyboard shortcuts

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