config

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2022 License: ISC Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvServerPort              = "server.port"
	EnvServerHost              = "server.host"
	EnvServerSwaggerEnabled    = "server.swagger.enabled"
	EnvServerSwaggerHost       = "server.swagger.host"
	EnvEnvironment             = "env.environment"
	EnvRegion                  = "env.region"
	EnvVersion                 = "env.version"
	EnvCommit                  = "env.commit"
	EnvBuildDate               = "env.builddate"
	EnvBitcoinNetwork          = "env.bitcoin.network"
	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"
	EnvDPPTimeout              = "dpp.timeout"
	EnvDPPHost                 = "dpp.host"
	EnvMAPIMinerName           = "mapi.minername"
	EnvMAPIURL                 = "mapi.minerurl"
	EnvMAPIToken               = "mapi.token"
	EnvMAPICallbackHost        = "mapi.callback.host"
	EnvSocketMaxMessageBytes   = "socket.maxmessage.bytes"
	EnvTransportHTTPEnabled    = "transport.http.enabled"
	EnvTransportSocketsEnabled = "transport.sockets.enabled"
	EnvPeerChannelsHost        = "peerchannels.host"
	EnvPeerChannelsPath        = "peerchannels.path"
	EnvPeerChannelsTTL         = "peerchannels.ttl.minutes"

	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.

Types

type Config

type Config struct {
	Logging       *Logging
	Server        *Server
	Deployment    *Deployment
	Db            *Db
	HeadersClient *HeadersClient
	Wallet        *Wallet
	PeerChannels  *PeerChannels
	DPP           *DPP
	Mapi          *MApi
	Socket        *Socket
	Transports    *Transports
}

Config returns strongly typed config values.

func (*Config) Validate

func (c *Config) Validate() error

Validate will ensure the config matches certain parameters.

type ConfigurationLoader

type ConfigurationLoader interface {
	WithServer() ConfigurationLoader
	WithDb() ConfigurationLoader
	WithDeployment(app string) ConfigurationLoader
	WithLog() ConfigurationLoader
	WithWallet() ConfigurationLoader
	WithDPP() ConfigurationLoader
	WithHeadersClient() ConfigurationLoader
	WithSocket() ConfigurationLoader
	WithTransports() ConfigurationLoader
	WithMapi() ConfigurationLoader
	WithPeerChannels() ConfigurationLoader
	Load() *Config
}

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

type DPP added in v0.1.6

type DPP struct {
	Timeout    int
	ServerHost string
}

DPP contains information relating to a DPP interactions.

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
}

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
	CallbackHost string
}

MApi contains MAPI connection settings.

type NetworkType added in v0.0.8

type NetworkType string

NetworkType is used to restrict the networks we can support.

const (
	NetworkRegtest NetworkType = "regtest"
	NetworkSTN     NetworkType = "stn"
	NetworkTestnet NetworkType = "testnet"
	NetworkMainet  NetworkType = "mainnet"
)

Supported bitcoin network types.

func (NetworkType) String added in v0.1.1

func (n NetworkType) String() string

type PeerChannels added in v0.1.3

type PeerChannels struct {
	// Host the peer channels host.
	Host string
	// Path to peer channels.
	Path string
	// TTL the life of the peer channel.
	TTL time.Duration
}

PeerChannels information relating to peer channel interactions.

type Server

type Server struct {
	Port     string
	Hostname 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 added in v0.1.1

type Socket struct {
	MaxMessageBytes  int
	ClientIdentifier string
}

Socket contains the socket config for this server if running sockets.

type Transports added in v0.1.1

type Transports struct {
	HTTPEnabled    bool
	SocketsEnabled bool
}

Transports enables or disables dpp transports.

type ViperConfig added in v0.1.1

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 added in v0.1.1

func (v *ViperConfig) Load() *Config

Load will return the underlying config setup.

func (*ViperConfig) WithDPP added in v0.1.6

func (v *ViperConfig) WithDPP() ConfigurationLoader

WithDPP sets up and return dpp interface configuration.

func (*ViperConfig) WithDb added in v0.1.1

func (v *ViperConfig) WithDb() ConfigurationLoader

WithDb sets up and returns database configuration.

func (*ViperConfig) WithDeployment added in v0.1.1

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

WithDeployment sets up the deployment configuration if required.

func (*ViperConfig) WithHeadersClient added in v0.1.1

func (v *ViperConfig) WithHeadersClient() ConfigurationLoader

WithHeadersClient sets up and returns headers client configuration.

func (*ViperConfig) WithLog added in v0.1.1

func (v *ViperConfig) WithLog() ConfigurationLoader

WithLog sets up and returns log config.

func (*ViperConfig) WithMapi added in v0.1.1

func (v *ViperConfig) WithMapi() ConfigurationLoader

WithMapi will setup Mapi settings.

func (*ViperConfig) WithPeerChannels added in v0.1.3

func (v *ViperConfig) WithPeerChannels() ConfigurationLoader

WithPeerChannels reads peer channels config.

func (*ViperConfig) WithServer added in v0.1.1

func (v *ViperConfig) WithServer() ConfigurationLoader

WithServer will setup the web server configuration if required.

func (*ViperConfig) WithSocket added in v0.1.1

func (v *ViperConfig) WithSocket() ConfigurationLoader

WithSocket will setup Mapi settings.

func (*ViperConfig) WithTransports added in v0.1.1

func (v *ViperConfig) WithTransports() ConfigurationLoader

WithTransports reads transport config.

func (*ViperConfig) WithWallet added in v0.1.1

func (v *ViperConfig) WithWallet() ConfigurationLoader

WithWallet sets up and returns merchant wallet configuration.

type Wallet

type Wallet struct {
	Network            NetworkType
	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