config

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Port fs db server port.
	//  Default: 8888
	//  Env: PORT
	Port int `yaml:"port"`

	// Storage fs db storage options.
	Storage Storage `yaml:"storage"`

	// WPool worker pool options.
	WPool WPool `yaml:"wPool"`
}

Config provides fs db configuration options.

Default:
  port: 8888
  storage:
    dbPath: test_db
    maxDirCount: 1000000
    rootDirs:
      - ./testStorage
    gcPeriod: 1m
  wPool:
    numWorkers: runtime.GOMAXPROCS(0)
    sendDuration: 1ms

func ParseConfig

func ParseConfig(confFile string) (Config, error)

ParseConfig returns filled Config options from a configuration file.

func (*Config) ParseEnv

func (c *Config) ParseEnv() error

ParseEnv fills the config options with environment variables.

type Storage

type Storage struct {
	// DbPath path to badger database directory.
	//	Default: test_db
	//	Env: DB_PATH
	DbPath string `yaml:"dbPath"`

	// MaxDirCount max number of files in one subdirectory.
	//	Default: 1_000_000
	//	Env: DIR_COUNT
	MaxDirCount uint64 `yaml:"maxDirCount"`

	// RootDirs slice with root directories.
	//	Default: ["./testStorage"]
	//	Env: ROOT_DIRS
	RootDirs []string `yaml:"rootDirs"`

	// GCPeriod period for run the mechanism for deleting old versions of files.
	//	Default: 1m
	//	Env: GC_PERIOD
	GCPeriod time.Duration `yaml:"gcPeriod"`
}

Storage provides configuration options for fs db storage.

Default:
  dbPath: test_db
  maxDirCount: 1000000
  rootDirs:
    - ./testStorage
  gcPeriod: 1m

func (*Storage) ParseEnv

func (s *Storage) ParseEnv() (err error)

ParseEnv fills the storage options with environment variables.

func (*Storage) Valid

func (s *Storage) Valid() error

Valid validates the storage options.

type WPool added in v1.1.0

type WPool struct {
	// NumWorkers the number of workers in a worker pool that can work at the same time.
	//	Default: runtime.GOMAXPROCS(0)
	//	Env: NUM_WORKERS
	NumWorkers int `yaml:"numWorkers"`

	// SendDuration the maximum duration of wait for an event to be sent to the worker pool.
	//	Default: 1ms
	//	Env: SEND_DURATION
	SendDuration time.Duration `yaml:"sendDuration"`
}

WPool provides configuration options for a worker pool.

Default:
  numWorkers: runtime.GOMAXPROCS(0)
  sendDuration: 1ms

func (*WPool) ParseEnv added in v1.1.0

func (wp *WPool) ParseEnv() (err error)

ParseEnv fills the storage options with environment variables.

Jump to

Keyboard shortcuts

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