config

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2021 License: ISC Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvServerPort           = "server.port"
	EnvServerHost           = "server.host"
	EnvEnvironment          = "env.environment"
	EnvMainNet              = "env.mainnet"
	EnvRegion               = "env.region"
	EnvVersion              = "env.version"
	EnvCommit               = "env.commit"
	EnvBuildDate            = "env.builddate"
	EnvLogLevel             = "log.level"
	EnvDb                   = "db.type"
	EnvDbSchema             = "db.schema.path"
	EnvDbDsn                = "db.dsn"
	EnvDbMigrate            = "db.migrate"
	EnvHeadersClientAddress = "headersclient.address"
	EnvHeadersClientTimeout = "headersclient.timeout"
	EnvNetwork              = "wallet.network"
	EnvWalletSpvRequired    = "wallet.spvrequired"
	EnvPaymentExpiry        = "wallet.paymentexpiry"
	EnvP4Timeout            = "p4.timeout"
	EnvMAPIMinerName        = "mapi.minername"
	EnvMAPIURL              = "mapi.minerurl"
	EnvMAPIToken            = "mapi.token"

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

Environment variable constants.

Variables

This section is empty.

Functions

func SetupDefaults

func SetupDefaults()

SetupDefaults will setup default config values. These can all be overwritten by environment variables.

func SetupLog

func SetupLog(cfg *Logging)

SetupLog will setup the logger.

Types

type Config

type Config struct {
	Logging       *Logging
	Server        *Server
	Deployment    *Deployment
	Db            *Db
	HeadersClient *HeadersClient
	Wallet        *Wallet
	P4            *P4
	Mapi          *MApi
}

Config returns strongly typed config values.

func NewViperConfig

func NewViperConfig(appname string) *Config

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

func (*Config) Validate

func (c *Config) Validate() error

Validate will ensure the config matches certain parameters.

func (*Config) WithDb

func (c *Config) WithDb() *Config

WithDb sets up and returns database configuration.

func (*Config) WithDeployment

func (c *Config) WithDeployment(appName string) *Config

WithDeployment sets up the deployment configuration if required.

func (*Config) WithHeadersClient

func (c *Config) WithHeadersClient() *Config

WithHeadersClient sets up and returns headers client configuration.

func (*Config) WithLog

func (c *Config) WithLog() *Config

WithLog sets up and returns log config.

func (*Config) WithMapi

func (c *Config) WithMapi() *Config

WithMapi will setup Mapi settings.

func (*Config) WithP4 added in v0.0.2

func (c *Config) WithP4() *Config

WithP4 sets up and return p4 interface configuration.

func (*Config) WithServer

func (c *Config) WithServer() *Config

WithServer will setup the web server configuration if required.

func (*Config) WithWallet

func (c *Config) WithWallet() *Config

WithWallet sets up and returns merchant wallet configuration.

type ConfigurationLoader

type ConfigurationLoader interface {
	WithServer() *Config
	WithDb() *Config
	WithDeployment(app string) *Config
	WithLog() *Config
	WithPaymail() *Config
	WithWallet() *Config
	WithP4() *Config
	WithHeadersClient() *Config
}

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

type Db

type Db struct {
	Type       DbType
	SchemaPath string
	Dsn        string
	MigrateDb  bool
}

Db contains database information.

type DbType

type DbType string

DbType is used to restrict the dbs we can support.

const (
	DBSqlite   DbType = "sqlite"
	DBMySQL    DbType = "mysql"
	DBPostgres DbType = "postgres"
)

Supported database types.

type Deployment

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

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 HeadersClient

type HeadersClient struct {
	Address string
	Timeout int
}

HeadersClient contains HeadersClient information.

type Logging

type Logging struct {
	Level string
}

Logging contains log configuration.

type MApi

type MApi struct {
	MinerName string
	URL       string
	Token     string
}

MApi contains MAPI connection settings.

type P4 added in v0.0.2

type P4 struct {
	Timeout int
}

P4 contains information relating to a p4 interactions.

type Server

type Server struct {
	Port     string
	Hostname string
}

Server contains all settings required to run a web server.

type Wallet

type Wallet struct {
	Network            string
	SPVRequired        bool
	PaymentExpiryHours int64
}

Wallet contains information relating to a payd installation.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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