option

package
v0.0.23 Latest Latest
Warning

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

Go to latest
Published: May 1, 2022 License: MIT Imports: 5 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")
)

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"
)

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 WithHealthCheck

func WithHealthCheck() Option

func WithListenPort

func WithListenPort(port int) Option

func WithMessageQueues added in v0.0.6

func WithMessageQueues(mqs ...mq.MQ) 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

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

	// ServerCerts ...
	ServerCerts *certs

	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