config

package
v0.0.0-...-def7031 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProviderKraken  = "kraken"
	ProviderBinance = "binance"
)

Variables

View Source
var (

	// ErrEmptyConfigPath defines a sentinel error for an empty config path.
	ErrEmptyConfigPath = errors.New("empty configuration file path")

	// SupportedProviders defines a lookup table of all the supported currency API
	// providers.
	SupportedProviders = map[string]struct{}{
		ProviderKraken:  {},
		ProviderBinance: {},
	}
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Server        Server         `toml:"server"`
	CurrencyPairs []CurrencyPair `toml:"currency_pairs" validate:"required,gt=0,dive,required"`
}

Config defines all necessary price-feeder configuration parameters.

func ParseConfig

func ParseConfig(configPath string) (Config, error)

ParseConfig attempts to read and parse configuration from the given file path. An error is returned if reading or parsing the config fails.

func (Config) Validate

func (c Config) Validate() error

Validate returns an error if the Config object is invalid.

type CurrencyPair

type CurrencyPair struct {
	Base      string   `toml:"base" validate:"required"`
	Quote     string   `toml:"quote" validate:"required"`
	Providers []string `toml:"providers" validate:"required,gt=0,dive,required"`
}

CurrencyPair defines a price quote of the exchange rate for two different currencies and the supported providers for getting the exchange rate.

type Server

type Server struct {
	ListenAddr     string   `toml:"listen_addr"`
	WriteTimeout   string   `toml:"write_timeout"`
	ReadTimeout    string   `toml:"read_timeout"`
	VerboseCORS    bool     `toml:"verbose_cors"`
	AllowedOrigins []string `toml:"allowed_origins"`
}

Server defines the API server configuration.

Jump to

Keyboard shortcuts

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