option

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingServerName = errors.New("missing server name")
	ErrInvalidPort       = errors.New("invalid port number")
)
View Source
var DefaultOptions = Options{
	ListenPort:     8888,
	ENV:            Development,
	DBs:            make(map[string]database.Database),
	MQs:            make(map[string]mq.MQ),
	HealthCheck:    false,
	MetricsEnabled: false,
	StackSkip:      1,
}

Functions

This section is empty.

Types

type Consul

type Consul struct {
	Address    string
	Token      string
	DataCenter string
	// Prefix default value will be the current environment's name
	Prefix string
}

type Environment

type Environment string
const (
	Development Environment = "development"
	Production  Environment = "production"
	// Foundation is a special environment that should not be used for each services
	Foundation Environment = "foundation"
)

func (Environment) String

func (e Environment) String() string

type Option

type Option func(*Options)

func WithConsul

func WithConsul(c Consul) Option

func WithDatabases

func WithDatabases(dbs ...database.Database) Option

func WithEnvironment

func WithEnvironment(env Environment) Option

WithEnvironment sets the env

func WithExitListeners

func WithExitListeners(listeners ...life.Listener) Option

func WithFilters added in v0.0.3

func WithFilters(filters ...filter.ServerFilter) Option

WithFilters will bind a set of filters to the server uses

func WithHealthCheck

func WithHealthCheck() Option

func WithListenPort

func WithListenPort(port int) Option

func WithMessageQueues

func WithMessageQueues(mqs ...mq.MQ) Option

func WithMetrics

func WithMetrics() Option

func WithPlugins

func WithPlugins(plugins ...plugin.Plugin) Option

func WithRestartListeners

func WithRestartListeners(listeners ...life.Listener) Option

func WithServerCerts

func WithServerCerts(pubkey []byte, prikey []byte) Option

func WithServerName

func WithServerName(name string) Option

func WithStackSkip

func WithStackSkip(i int) Option

type Options

type Options struct {
	// ID is the service ID
	ID             string
	ServerName     string
	ListenPort     int
	ENV            Environment
	ConsulCenter   Consul
	DBs            map[string]database.Database
	MQs            map[string]mq.MQ
	HealthCheck    bool
	MetricsEnabled bool

	// StackSkip for logging that it can be used to debug stacks
	// default: 1
	StackSkip int
	Plugins   []plugin.Plugin

	// ServerCerts ...
	ServerCerts *certs

	// ServerFilters defines all the customized filters that the server uses
	ServerFilters []filter.ServerFilter

	WhenExit    []life.Listener
	WhenRestart []life.Listener
}

Option defines

func (Options) Valid

func (o Options) Valid() error

Jump to

Keyboard shortcuts

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