config

package
v0.0.0-...-c2add7f Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2023 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package config contains configuration parsing logic and provides metrics agent and server configuration objects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadFromFile

func LoadFromFile(src entity.FilePath, dst Config) error

LoadFromFile overwrites the provided config with data from configuration file.

Types

type Agent

type Agent struct {
	PollInterval   time.Duration     `env:"POLL_INTERVAL" json:"poll_interval"`
	ReportInterval time.Duration     `env:"REPORT_INTERVAL" json:"report_interval"`
	Address        entity.NetAddress `env:"ADDRESS" json:"address"`
	Transport      string            `env:"TRANSPORT" json:"transport"`
	Secret         security.Secret   `env:"KEY" json:"key"`
	PublicKeyPath  entity.FilePath   `env:"CRYPTO_KEY" json:"crypto_key"`
	PollTimeout    time.Duration     `json:"-"`
	ExportTimeout  time.Duration     `json:"-"`
	Debug          bool              `env:"DEBUG" json:"debug"`
}

func NewAgent

func NewAgent() *Agent

func (*Agent) Parse

func (c *Agent) Parse() error

func (Agent) String

func (c Agent) String() string

func (*Agent) UnmarshalJSON

func (c *Agent) UnmarshalJSON(data []byte) error

type Config

type Config interface {
	UnmarshalJSON(data []byte) error
	String() string
}

Config represents generic service configuration.

type Server

type Server struct {
	Address        entity.NetAddress    `env:"ADDRESS" json:"address"`
	GRPCAddress    entity.NetAddress    `env:"GRPC_ADDRESS" json:"grpc_address"`
	StoreInterval  time.Duration        `env:"STORE_INTERVAL" json:"store_interval"`
	StorePath      string               `env:"STORE_FILE" json:"store_file"`
	RestoreOnStart bool                 `env:"RESTORE" json:"restore"`
	Secret         security.Secret      `env:"KEY" json:"key"`
	PrivateKeyPath entity.FilePath      `env:"CRYPTO_KEY" json:"crypto_key"`
	TrustedSubnet  *net.IPNet           `env:"TRUSTED_SUBNET" json:"trusted_subnet"`
	DatabaseURL    security.DatabaseURL `env:"DATABASE_DSN" json:"database_dsn"`
	PprofAddress   entity.NetAddress    `env:"PPROF_ADDRESS" json:"pprof_address"`
	Debug          bool                 `env:"DEBUG" json:"debug"`
}

func NewServer

func NewServer() *Server

func (*Server) Parse

func (c *Server) Parse() error

func (Server) String

func (c Server) String() string

func (*Server) UnmarshalJSON

func (c *Server) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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