config

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2022 License: ISC Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvServerPort                  = "server.port"
	EnvServerHost                  = "server.host"
	EnvServerFQDN                  = "server.fqdn"
	EnvServerSwaggerEnabled        = "server.swagger.enabled"
	EnvServerSwaggerHost           = "server.swagger.host"
	EnvEnvironment                 = "env.environment"
	EnvRegion                      = "env.region"
	EnvVersion                     = "env.version"
	EnvCommit                      = "env.commit"
	EnvBuildDate                   = "env.builddate"
	EnvLogLevel                    = "log.level"
	EnvPaydHost                    = "payd.host"
	EnvPaydPort                    = "payd.port"
	EnvPaydSecure                  = "payd.secure"
	EnvPaydCertPath                = "payd.cert.path"
	EnvPaydNoop                    = "payd.noop"
	EnvSocketChannelTimeoutSeconds = "socket.channel.timeoutseconds"
	EnvSocketMaxMessageBytes       = "socket.maxmessage.bytes"
	EnvTransportMode               = "transport.mode"

	LogDebug = "debug"
	LogInfo  = "info"
	LogError = "error"
	LogWarn  = "warn"

	TransportModeHybrid = "hybrid"
	TransportModeHTTP   = "http"
	TransportModeSocket = "socket"
)

Environment variable constants.

Variables

This section is empty.

Functions

func SetupDefaults

func SetupDefaults()

SetupDefaults will set environment variables to default values.

These can be overwritten when running the service.

Types

type Config

type Config struct {
	Logging    *Logging
	Server     *Server
	Deployment *Deployment
	PayD       *PayD
	Sockets    *Socket
	Transports *Transports
}

Config returns strongly typed config values.

func (*Config) Validate

func (c *Config) Validate() error

Validate the configuration.

type ConfigurationLoader

type ConfigurationLoader interface {
	WithServer() ConfigurationLoader
	WithDeployment(app string) ConfigurationLoader
	WithLog() ConfigurationLoader
	WithPayD() ConfigurationLoader
	WithSockets() ConfigurationLoader
	WithTransports() ConfigurationLoader
	Load() *Config
}

ConfigurationLoader will load configuration items into a struct that contains a configuration.

type Deployment

type Deployment struct {
	Environment string
	AppName     string
	Region      string
	Version     string
	Commit      string
	BuildDate   time.Time
}

Deployment contains information relating to the current deployed instance.

func (*Deployment) IsDev

func (d *Deployment) IsDev() bool

IsDev determines if this app is running on a dev environment.

func (*Deployment) String

func (d *Deployment) String() string

type Logging

type Logging struct {
	Level string
}

Logging contains log configuration.

type PayD

type PayD struct {
	Host            string
	Port            string
	Secure          bool
	CertificatePath string
	Noop            bool
}

PayD is used to setup connection to a payd instance. In this case, we connect to only one merchant wallet implementors may need to connect to more.

type Server

type Server struct {
	Port     string
	Hostname string
	// FQDN - fully qualified domain name, used to form the paymentRequest
	// payment URL as this may be different from the hostname + port.
	FQDN string
	// SwaggerEnabled if true we will include an endpoint to serve swagger documents.
	SwaggerEnabled bool
	SwaggerHost    string
}

Server contains all settings required to run a web server.

type Socket

type Socket struct {
	MaxMessageBytes int
	ChannelTimeout  time.Duration
}

Socket contains config items for a socket server.

type Transports

type Transports struct {
	Mode string
}

Transports enables or disables dpp transports.

type ViperConfig

type ViperConfig struct {
	*Config
}

ViperConfig contains viper based configuration data.

func NewViperConfig

func NewViperConfig(appname string) *ViperConfig

NewViperConfig will setup and return a new viper based configuration handler.

func (*ViperConfig) Load

func (v *ViperConfig) Load() *Config

Load will return the underlying config setup.

func (*ViperConfig) WithDeployment

func (v *ViperConfig) WithDeployment(appName string) ConfigurationLoader

WithDeployment sets up the deployment configuration if required.

func (*ViperConfig) WithLog

func (v *ViperConfig) WithLog() ConfigurationLoader

WithLog sets up and returns log config.

func (*ViperConfig) WithPayD

func (v *ViperConfig) WithPayD() ConfigurationLoader

WithPayD sets up and returns PayD viper config.

func (*ViperConfig) WithServer

func (v *ViperConfig) WithServer() ConfigurationLoader

WithServer will setup the web server configuration if required.

func (*ViperConfig) WithSockets

func (v *ViperConfig) WithSockets() ConfigurationLoader

WithSockets reads socket env vars.

func (*ViperConfig) WithTransports

func (v *ViperConfig) WithTransports() ConfigurationLoader

WithTransports reads transport config.

Jump to

Keyboard shortcuts

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