config

package
v0.0.23 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ExampleConfig is primarily used to provide a template for generating the config file
	ExampleConfig = &Config{
		MainDiscordToken:  "CHANGEME-MAIN",
		InfuraAPIKey:      "INFURA-KEY",
		InfuraWSEnabled:   false,
		ETHRPCEndpoint:    "http://localhost:8545",
		MulticallContract: "0xFB6FdE35dDD2cC295908b1E5EfAF36Effb5C04dD",
		Watchers: []Watcher{
			{DiscordToken: "CHANGEME-TOKEN", Currency: "CHANGEME-CURRENCY"},
		},
		Database: Database{
			Type:           "sqlite",
			Host:           "localhost",
			Port:           "5432",
			User:           "user",
			Pass:           "pass",
			DBName:         "indexed",
			DBPath:         "/changeme",
			SSLModeDisable: false,
		},
		Indices: []string{"defi5", "cc10", "orcl5", "degen10"},
		Logger: Logger{
			Path:  "gondx.log",
			Debug: true,
			Dev:   true,
		},
	}
)

Functions

func LoggerFromConfig

func LoggerFromConfig(cfg *Config) (*zap.Logger, error)

LoggerFromConfig returns a logger from our config

func NewConfig

func NewConfig(path string) error

NewConfig generates a new config and stores at path

Types

type Config

type Config struct {
	// the token used by the main bot (NDXBot)
	MainDiscordToken string `yaml:"main_discord_token"`
	// if nil we dont use infura and connect directly to the rpc node below
	InfuraAPIKey      string    `yaml:"infura_api_key"`
	InfuraWSEnabled   bool      `yaml:"infura_ws_enabled"`
	ETHRPCEndpoint    string    `yaml:"eth_rpc_endpoint"`
	MulticallContract string    `yaml:"multicall_contract"`
	Watchers          []Watcher `yaml:"watchers"`
	Database          Database  `yaml:"database"`
	Logger            `yaml:"logger"`
	Indices           []string `yaml:"indices"`
}

Config bundles together discord configuration information

func LoadConfig

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

LoadConfig loads the configuration

type Database

type Database struct {
	Type           string `yaml:"type"` // sqlite or postgres, if sqlite all other options except DBName are ignored
	Host           string `yaml:"host"`
	Port           string `yaml:"port"`
	User           string `yaml:"user"`
	Pass           string `yaml:"pass"`
	DBName         string `yaml:"db_name"`
	DBPath         string `yaml:"db_path"`
	SSLModeDisable bool   `yaml:"ssl_mode_disable"`
}

Database provides configuration over our database connection

type Logger

type Logger struct {
	Path     string                 `yaml:"path"`
	Debug    bool                   `yaml:"debug"`
	Dev      bool                   `yaml:"dev"`
	FileOnly bool                   `yaml:"file_only"`
	Fields   map[string]interface{} `yaml:"fields"`
}

Logger provides configuration over zap logger

type Watcher

type Watcher struct {
	DiscordToken string `yaml:"discord_token"`
	Currency     string `yaml:"currency"`
}

Watcher is used to start a process that watches the price of a token and posts its value as a name

Jump to

Keyboard shortcuts

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