mpserver

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultLogLevel        = "info"
	DefaultShutdownTimeout = 10 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config added in v0.2.6

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

Config holds the configuration information for a multiprotocol server.

func NewConfig added in v0.2.6

func NewConfig(prefix ...string) (Config, error)

NewConfig returns the configuration of a multiprotocol server.

func (Config) LogLevel added in v0.2.6

func (c Config) LogLevel() string

LogLevel returns the logging level. The default level is "info".

func (Config) ShutdownTimeout added in v0.2.6

func (c Config) ShutdownTimeout() time.Duration

ShutdownTimeout returns the server shutdown timeout.

func (Config) ToOptions added in v0.2.7

func (c Config) ToOptions() []Option

type MultiprotocolServer

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

MultiprotocolServer manages servers that provide services with mutliple protocols.

func New

func New(version, branch, commit, date string, opts ...Option) (*MultiprotocolServer, error)

New returns a new multiprotocol server.

func (MultiprotocolServer) Ctx

Ctx returns the context used by this server.

func (*MultiprotocolServer) Register added in v0.2.7

func (s *MultiprotocolServer) Register(ctx context.Context, servers ...ProtocolServer)

func (MultiprotocolServer) Serve

func (s MultiprotocolServer) Serve() error

Serve starts the protocol servers, waits for them to start (or fail), and then shuts down the servers.

func (MultiprotocolServer) Shutdown

func (s MultiprotocolServer) Shutdown()

Shutdown halts the server.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option provides options for configuring the creation of a multiprotocol server.

func WithLogLevel

func WithLogLevel(logLevel string) Option

WithLogLevel sets the loglevel for the multiprotocol server.

func WithShutdownTimeout

func WithShutdownTimeout(d time.Duration) Option

WithShutdownTimeout defines the maximum amount of time allowed to gracefully shutdown the protocol servers.

type ProtocolServer

type ProtocolServer interface {
	// Serve starts the server. This will be run in its own go routine.
	Serve(context.Context) error

	// Shutdown a protocol server. Calling shutdown for a server that returns
	// an erro from Serve must be a noop.
	Shutdown(context.Context)

	// Name returns the name of the server.
	Name() string
}

ProtocolServer defines the behavior expended from a protocol server.

Jump to

Keyboard shortcuts

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