configuration

package
v0.0.0-...-803e70e Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package configuration is used to store agent and server configuration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Address          string `env:"ADDRESS" json:"address"`
	FileStoragePath  string `env:"FILE_STORAGE_PATH"  json:"store_file"`
	Database         string `env:"DATABASE_DSN" json:"database_dsn"`
	ConfigFile       string `env:"CONFIG"`
	PrivateCryptoKey string `env:"CRYPTO_KEY" json:"crypto_key"`
	TrustedSubnet    string `env:"TRUSTED_SUBNET" json:"trusted_subnet"`
	CertFilePath     string `env:"CERTIFICATE" json:"certificate"`
	Key              []byte
	StoreInterval    int  `env:"STORE_INTERVAL" json:"store_interval"`
	Restore          bool `env:"RESTORE" json:"restore"`
	UseProtobuff     bool `env:"USE_PROTOBUFF" json:"use_protobuff"`
}

Config contains configuration for server.

func Parse

func Parse() (*Config, error)

Parse - return parsed config.

Environment variables have higher priority over command line variables and config file. Command line variables have higher priority over variables from config file.

func (*Config) String

func (c *Config) String() string

func (*Config) UnmarshalJSON

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

UnmarshalJSON - For anmarshaling of the time parameters of the configuration file.

type ConfigAgent

type ConfigAgent struct {
	Server          string `env:"ADDRESS" json:"address,omitempty"`
	Path            string `env:"CONFIG"`
	PublicCryptoKey string `env:"CRYPTO_KEY" json:"crypto_key"`
	CertFilePath    string `env:"CERTIFICATE" json:"certificate"`
	Key             []byte
	PollInterval    int  `env:"POLL_INTERVAL" json:"poll_interval,omitempty"`
	ReportInterval  int  `env:"REPORT_INTERVAL" json:"report_interval,omitempty"`
	Limit           int  `env:"RATE_LIMIT"`
	UseProtobuff    bool `env:"USE_PROTOBUFF" json:"use_protobuff"`
}

ConfigAgent contains configuration for agent.

func ParseAgent

func ParseAgent() (*ConfigAgent, error)

ParseAgent - return parsed config.

Environment variables have higher priority over command line variables and config file. Command line variables have higher priority over variables from config file.

func (*ConfigAgent) String

func (c *ConfigAgent) String() string

func (*ConfigAgent) UnmarshalJSON

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

UnmarshalJSON - For anmarshaling of the time parameters of the configuration file.

Jump to

Keyboard shortcuts

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