config

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppName    = "polkadothub-indexer"
	AppVersion = "0.10.2"
	GitCommit  = "-"
	GoVersion  = "1.14"
)

Variables

This section is empty.

Functions

func FromEnv

func FromEnv(config *Config) error

FromEnv reads the config from environment variables

func FromFile

func FromFile(path string, config *Config) error

FromFile reads the config from a file

func VersionString

func VersionString() string

Types

type Config

type Config struct {
	Network                      string `json:"network" envconfig:"NETWORK"`
	ChainID                      string `json:"chain_id" envconfig:"CHAIN_ID"`
	AppEnv                       string `json:"app_env" envconfig:"APP_ENV" default:"development"`
	ProxyUrl                     string `json:"proxy_url" envconfig:"PROXY_URL"`
	ServerAddr                   string `json:"server_addr" envconfig:"SERVER_ADDR" default:"0.0.0.0"`
	ServerPort                   int64  `json:"server_port" envconfig:"SERVER_PORT" default:"8081"`
	FirstBlockHeight             int64  `json:"first_block_height" envconfig:"FIRST_BLOCK_HEIGHT" default:"1"`
	IndexWorkerInterval          string `json:"index_worker_interval" envconfig:"INDEX_WORKER_INTERVAL" default:"@every 15m"`
	SummarizeWorkerInterval      string `json:"summarize_worker_interval" envconfig:"SUMMARIZE_WORKER_INTERVAL" default:"@every 20m"`
	PurgeWorkerInterval          string `json:"purge_worker_interval" envconfig:"PURGE_WORKER_INTERVAL" default:"@every 1h"`
	DefaultBatchSize             int64  `json:"default_batch_size" envconfig:"DEFAULT_BATCH_SIZE" default:"0"`
	DatabaseDSN                  string `json:"database_dsn" envconfig:"DATABASE_DSN"`
	Debug                        bool   `json:"debug" envconfig:"DEBUG"`
	LogLevel                     string `json:"log_level" envconfig:"LOG_LEVEL" default:"info"`
	LogOutput                    string `json:"log_output" envconfig:"LOG_OUTPUT" default:"stdout"`
	IndexerMetricAddr            string `json:"indexer_metric_addr" envconfig:"INDEXER_METRIC_ADDR" default:":8080"`
	ServerMetricAddr             string `json:"server_metric_addr" envconfig:"SERVER_METRIC_ADDR" default:":8090"`
	PurgeSequencesInterval       string `json:"purge_sequences_interval" envconfig:"PURGE_SEQUENCES_INTERVAL" default:"26h"`
	PurgeHourlySummariesInterval string `json:"purge_hourly_summaries_interval" envconfig:"PURGE_HOURLY_SUMMARIES_INTERVAL" default:"26h"`
	IndexerConfigFile            string `json:"indexer_config_file" envconfig:"INDEXER_CONFIG_FILE" default:"indexer_config.json"`
	RouteToLive                  string `json:"route_to_live" envconfig:"ROUTE_TO_LIVE"`

	DatastoreGRPCAddr string `json:"datastore_grpc_addr" envconfig:"DATASTORE_GRPC_ADDR"`
	DatastoreKey      string `json:"datastore_key" envconfig:"DATASTORE_KEY"`
	GrpcMaxRecvSize   int    `json:"grpc_max_recv_size" envconfig:"GRPC_MAX_RECV_SIZE" default:"1073741824"` // 1024^3
	GrpcMaxSendSize   int    `json:"grpc_max_send_size" envconfig:"GRPC_MAX_SEND_SIZE" default:"1073741824"` // 1024^3

	RewardsHTTPStoreAddress string `json:"rewards_http_store_address" envconfig:"REWARDS_HTTP_STORE_ADDRESS"`
}

Config holds the configuration data

func New

func New() *Config

New returns a new config

func (*Config) IsDevelopment

func (c *Config) IsDevelopment() bool

IsDevelopment returns true if app is in dev mode

func (*Config) IsProduction

func (c *Config) IsProduction() bool

IsProduction returns true if app is in production mode

func (*Config) ListenAddr

func (c *Config) ListenAddr() string

ListenAddr returns a full listen address and port

func (*Config) Validate

func (c *Config) Validate() error

Validate returns an error if config is invalid

Jump to

Keyboard shortcuts

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