Documentation ¶
Index ¶
- Variables
- func BytesToUnitString(bytes uint64) string
- func ConsolidateEnvVars(conf *Config)
- func LoadDiskConfig()
- func ParsePoolSize(dip DiskInfoProvider)
- func ParseWellFormedPoolSize(str string) uint64
- type Config
- type DiskInfo
- func (di *DiskInfo) GetAvailableBytes() uint64
- func (di *DiskInfo) GetDiskInfo() *DiskInfo
- func (di *DiskInfo) GetPoolSizeBytes() uint64
- func (di *DiskInfo) GetPrettyPoolSize() string
- func (di *DiskInfo) Init()
- func (di *DiskInfo) Refresh()
- func (di *DiskInfo) SetAvailableBytes(new uint64)
- func (di *DiskInfo) SetPoolSizeBytes(new uint64)
- type DiskInfoProvider
- type KeySet
- type Status
Constants ¶
This section is empty.
Variables ¶
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 )
var ( // Keysets is the configuration structure for the known keysets. Keysets []KeySet )
Functions ¶
func BytesToUnitString ¶
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 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:
- A base-10 number, can be floating point
- 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 ¶
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 ¶
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 ¶
GetAvailableBytes gets the number of bytes still free on the drive.
func (*DiskInfo) GetDiskInfo ¶
GetDiskInfo returns the disk info struct.
func (*DiskInfo) GetPoolSizeBytes ¶
GetPoolSizeBytes returns the size of the storage pool.
func (*DiskInfo) GetPrettyPoolSize ¶
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 ¶
SetAvailableBytes sets the number of free bytes on the drive.
func (*DiskInfo) SetPoolSizeBytes ¶
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.