config

package
v0.0.0-...-862ce61 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseDB

type BaseDB struct {
	MaxConns        int   `json:"maxConns"`
	MaxConnLifetime int64 `json:"maxConnLifetime"` // in seconds
	Threads         int   `json:"threads"`
	Retry           Retry `json:"retry"`
	Timeout         int64 `json:"timeout"` // in seconds
}

BaseDB type definition for db configuration

type BaseRPC

type BaseRPC struct {
	Threads int   `json:"threads"`
	Timeout int   `json:"timeout"`
	Retry   Retry `json:"retry"`
}

BaseRPC type definition for base rpc configuration

type Coin

type Coin struct {
	Name string  `json:"name"`
	RPC  CoinRPC `json:"rpc"`
	ZMQ  ZMQ     `json:"zmq"`
	DB   CoinDB  `json:"db"`
}

Coin type definition for coin rpc and zmq config variables

type CoinDB

type CoinDB struct {
	ReadOnly  string `json:"readonly"`
	ReadWrite string `json:"readwrite"`
}

CoinDB type definition for coin db endpoints

type CoinRPC

type CoinRPC struct {
	URL      string `json:"url"`
	User     string `json:"user"`
	Password string `json:"password"`
}

CoinRPC type definition for coin rpc configuration

type Config

type Config struct {
	DB    BaseDB  `json:"db"`
	RPC   BaseRPC `json:"rpc"`
	Coins []Coin  `json:"coins"`
}

Config type definition for all config variables

func Get

func Get(path string) (*Config, error)

Get returns all config variables from the config specified by the path arguement

func (*Config) GetCoin

func (c *Config) GetCoin(coin string) (*Coin, error)

GetCoin returns the configuration of a coin

func (*Config) GetDBConfig

func (c *Config) GetDBConfig(db DatabaseType, cc *Coin) (*DB, error)

GetDBConfig will return a DB that consists of the BaseDB along with the specified CoinDB

func (*Config) GetRPCConfig

func (c *Config) GetRPCConfig(cc *Coin) *RPC

GetRPCConfig will return RPC that consists of the BaseRPC along with the specified CoinRPC

func (*Config) ListCoins

func (c *Config) ListCoins() []string

ListCoins returns a list of available coins

type DB

type DB struct {
	URI string
	BaseDB
	CoinDB
}

DB type definition to group BaseDB and CoinDB and URI config variables

type DatabaseType

type DatabaseType int

DatabaseType represents which db endpoint to be used

const (
	ReadOnly DatabaseType = iota
	ReadWrite
)

The defined database types are as follows

func (DatabaseType) String

func (a DatabaseType) String() string

String take the enum index and print out the associated name

type RPC

type RPC struct {
	BaseRPC
	CoinRPC
}

RPC type definition to group BaseRPC and CoinRPC config variables

type Retry

type Retry struct {
	Attempts int   `json:"attempts"`
	Sleep    int64 `json:"sleep,omitempty"` // in seconds
}

Retry type definition for retry attempts

type ZMQ

type ZMQ struct {
	Timeout       int64    `json:"timeout"` // in seconds
	SubURL        string   `json:"subUrl"`
	Subscriptions []string `json:"subs"`
}

ZMQ type definition for zmq configuration

Jump to

Keyboard shortcuts

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