options

package
v1.2.8 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2021 License: MIT Imports: 9 Imported by: 9

Documentation

Index

Constants

View Source
const DefaultRPCPort = 7070

DefaultRPCPort is the port that will be used for RPC connections if no other is specified

Variables

This section is empty.

Functions

This section is empty.

Types

type Environment added in v1.1.1

type Environment string
const (
	EnvironmentDevelopment Environment = "development"
	EnvironmentStaging     Environment = "staging"
	EnvironmentProduction  Environment = "production"
)

func ParseEnvironment added in v1.1.1

func ParseEnvironment(str string) Environment

func (Environment) IsDevelopment added in v1.1.1

func (e Environment) IsDevelopment() bool

func (Environment) IsProduction added in v1.1.1

func (e Environment) IsProduction() bool

func (Environment) IsStaging added in v1.1.1

func (e Environment) IsStaging() bool

type Option

type Option func(*Options)

Option represents a function that can be used to mutate an Options object

func IfEnvironment added in v1.1.1

func IfEnvironment(env Environment, opts ...Option) Option

IfEnvironment conditionally applies options if running under a specific environment.

Make sure this option comes after any WithEnvironment options, if any.

func IfNotEnvironment added in v1.1.1

func IfNotEnvironment(env Environment, opts ...Option) Option

IfNotEnvironment conditionally applies options if running under any environment except for a specific one.

Make sure this option comes after any WithEnvironment options, if any.

func Logger

func Logger(l logger.Logger) Option

Logger sets the logger that will receive the log messages sent by the library

func Name

func Name(name string) Option

Name sets the name of the service

func RPCPort added in v1.1.0

func RPCPort(port int16) Option

RPCPort sets the port in which this service's RPC will listen on, as well as the port in which other services' RPC servers are listening on. Defaults to DefaultRPCPort

func WithEnvironment added in v1.1.1

func WithEnvironment(e Environment) Option

WithEnvironment sets the environment that the service is running under

type Options

type Options struct {
	Name        string
	RPCPort     int16
	Environment Environment

	Logger    logger.Logger
	Codec     codec.Codec
	Transport transport.Transport
	Router    router.Router
	Broker    broker.Broker
	Config    config.Config
	Discovery discovery.Discovery
}

Options holds the configuration for a service instance

Jump to

Keyboard shortcuts

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