config

package
v0.0.0-...-622c3c6 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Global is the configuration struct for the application.
	Global Config
	// Flags is the live configuration of currently running modules.
	Flags Status
	// Disk is the configuration interface for the disk utilities.
	Disk DiskInfo
)
View Source
var (
	// Keysets is the configuration structure for the known keysets.
	Keysets []KeySet
)

Functions

func BytesToUnitString

func BytesToUnitString(bytes uint64) string

BytesToUnitString Given a number of bytes, Returns a string that represents the number of bytes in a sensible unit.

func ConsolidateEnvVars

func ConsolidateEnvVars(conf *Config)

ConsolidateEnvVars looks for discrepancies between environment variables and the internal config struct, preferring the value set in the environment variable. In this function, variables starting with "field" track values associated with the struct, and a "ev" prefix indicates the value is associated with the environment variable.

func LoadDiskConfig

func LoadDiskConfig()

LoadDiskConfig loads the Disk Configuration

func ParsePoolSize

func ParsePoolSize(dip DiskInfoProvider)

ParsePoolSize parses the string contained in the global config as the max pool size, and stores the value it comes up with in bytes in the struct GlobalDiskInfo. If for some reason the input cannot be understood or the user attempts to allocate more storage than they have available, a default value of the user's capacity minus 10 GB will be put in place. This means that the minimum amount of space a user must have available is 10 GB. The string must be in the following format and order:

  1. A base-10 number, can be floating point
  2. One of the following: B, KB, MB, GB, or TB. It's case sensitive to avoid bit/byte confusion.

There can be any amount of whitespace before and after either of the elements.

"3000MB", "  10GB   ", "10 GB", "1.75TB", ".5 TB" will all work.
"1.TB", "10gb", "0xfa5MB" will not work

func ParseWellFormedPoolSize

func ParseWellFormedPoolSize(str string) uint64

ParseWellFormedPoolSize parses a string that passed the regex test in ParsePoolSize(). It extracts the number and unit, returning the number of bytes indicated by the string. IE: parseWellFormedPoolSize("10GB") = 10,000,000,000

Types

type Config

type Config struct {
	General  general
	Database database
	Sources  sources
	Stats    stats
}

Config defines the configuration struct for importing settings from TOML.

type DiskInfo

type DiskInfo struct {
	AvailableBytes uint64
	PoolSizeBytes  uint64
}

DiskInfo is a struct that provides information about the mounted directory size.

var GlobalDiskInfo DiskInfo

GlobalDiskInfo is the Global Configuration struct for Arken disk stats

func (*DiskInfo) GetAvailableBytes

func (di *DiskInfo) GetAvailableBytes() uint64

GetAvailableBytes gets the number of bytes still free on the drive.

func (*DiskInfo) GetDiskInfo

func (di *DiskInfo) GetDiskInfo() *DiskInfo

GetDiskInfo returns the disk info struct.

func (*DiskInfo) GetPoolSizeBytes

func (di *DiskInfo) GetPoolSizeBytes() uint64

GetPoolSizeBytes returns the size of the storage pool.

func (*DiskInfo) GetPrettyPoolSize

func (di *DiskInfo) GetPrettyPoolSize() string

GetPrettyPoolSize outputs a pretty string of the pool size.

func (*DiskInfo) Init

func (di *DiskInfo) Init()

Init initializes a DiskInfo with methods that make unix system calls.

func (*DiskInfo) Refresh

func (di *DiskInfo) Refresh()

Refresh updates the info with a new syscall.

func (*DiskInfo) SetAvailableBytes

func (di *DiskInfo) SetAvailableBytes(new uint64)

SetAvailableBytes sets the number of free bytes on the drive.

func (*DiskInfo) SetPoolSizeBytes

func (di *DiskInfo) SetPoolSizeBytes(new uint64)

SetPoolSizeBytes sets the size of the storage pool.

type DiskInfoProvider

type DiskInfoProvider interface {
	Init()
	Refresh()
	GetAvailableBytes() uint64
	SetAvailableBytes(uint64)
	GetPoolSizeBytes() uint64
	SetPoolSizeBytes(uint64)
	GetPrettyPoolSize() string
}

DiskInfoProvider is an interface is what makes this part of the program cross platform. The Unix and windows version of DiskInfo implement this method interface.

type KeySet

type KeySet struct {
	URL              string
	LightHouseFileID string
	Replications     int
	Gateway          string
	StatsURL         string
}

KeySet defines the global structure housing the known keysets.

type Status

type Status struct {
	IndexingSets bool
}

Status defines where the program looks to tell if other processes are currently running

Jump to

Keyboard shortcuts

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