config

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Lang is the language to use for translation
	Lang = ffc("lang")
	// LogForceColor forces color to be enabled, even if we do not detect a TTY
	LogForceColor = ffc("log.forceColor")
	// LogLevel is the logging level
	LogLevel = ffc("log.level")
	// LogNoColor forces color to be disabled, even if we detect a TTY
	LogNoColor = ffc("log.noColor")
	// LogTimeFormat is a string format for timestamps
	LogTimeFormat = ffc("log.timeFormat")
	// LogUTC sets log timestamps to the UTC timezone
	LogUTC = ffc("log.utc")
	// LogFilename sets logging to file
	LogFilename = ffc("log.filename")
	// LogFilesize sets the size to roll logs at
	LogFilesize = ffc("log.filesize")
	// LogMaxBackups sets the maximum number of old files to keep
	LogMaxBackups = ffc("log.maxBackups")
	// LogMaxAge sets the maximum age at which to roll
	LogMaxAge = ffc("log.maxAge")
	// LogCompress sets whether to compress backups
	LogCompress = ffc("log.compress")
	// LogIncludeCodeInfo enables the report caller for including the calling file and line number
	LogIncludeCodeInfo = ffc("log.includeCodeInfo")
	// LogJSONEnabled enables JSON formatted logs rather than text
	LogJSONEnabled = ffc("log.json.enabled")
	// LogJSONTimestampField configures the JSON key containing the timestamp of the log
	LogJSONTimestampField = ffc("log.json.fields.timestamp")
	// LogJSONLevelField configures the JSON key containing the log level
	LogJSONLevelField = ffc("log.json.fields.level")
	// LogJSONMessageField configures the JSON key containing the log message
	LogJSONMessageField = ffc("log.json.fields.message")
	// LogJSONFuncField configures the JSON key containing the calling function
	LogJSONFuncField = ffc("log.json.fields.func")
	// LogJSONFileField configures the JSON key containing the calling file
	LogJSONFileField = ffc("log.json.fields.file")
)

The following keys can be access from the root configuration. Plugins are responsible for defining their own keys using the Config interface

Functions

func GenerateConfigMarkdown

func GenerateConfigMarkdown(ctx context.Context, keys []string) ([]byte, error)

func Get

func Get(key RootKey) interface{}

Get gets a configuration in raw form

func GetBool

func GetBool(key RootKey) bool

GetBool gets a configuration bool

func GetByteSize

func GetByteSize(key RootKey) int64

GetByteSize get a size in bytes

func GetConfig

func GetConfig() fftypes.JSONObject

func GetDuration

func GetDuration(key RootKey) time.Duration

GetDuration gets a configuration time duration with consistent semantics

func GetFloat64

func GetFloat64(key RootKey) float64

GetFloat64 gets a configuration uint

func GetInt

func GetInt(key RootKey) int

GetInt gets a configuration uint

func GetInt64

func GetInt64(key RootKey) int64

GetInt64 gets a configuration uint

func GetKnownKeys

func GetKnownKeys() []string

GetKnownKeys gets the known keys

func GetObject

func GetObject(key RootKey) fftypes.JSONObject

GetObject gets a configuration map

func GetObjectArray

func GetObjectArray(key RootKey) fftypes.JSONObjectArray

GetObjectArray gets an array of configuration maps

func GetString

func GetString(key RootKey) string

GetString gets a configuration string

func GetStringSlice

func GetStringSlice(key RootKey) []string

GetStringSlice gets a configuration string array

func GetUint

func GetUint(key RootKey) uint

GetUint gets a configuration uint

func MergeConfig

func MergeConfig(configRecords []*fftypes.ConfigRecord) error

func ReadConfig

func ReadConfig(cfgSuffix, cfgFile string) error

ReadConfig initializes the config

func RootConfigReset

func RootConfigReset(setServiceDefaults ...func())

func Set

func Set(key RootKey, value interface{})

Set allows runtime setting of config (used in unit tests)

func SetupLogging

func SetupLogging(ctx context.Context)

SetupLogging initializes logging

Types

type KeySet

type KeySet interface {
	AddKnownKey(key string, defValue ...interface{})
}

type Prefix

type Prefix interface {
	KeySet
	SetDefault(key string, defValue interface{})
	SubPrefix(suffix string) Prefix
	Array() PrefixArray
	Set(key string, value interface{})
	Resolve(key string) string

	GetString(key string) string
	GetBool(key string) bool
	GetInt(key string) int
	GetInt64(key string) int64
	GetByteSize(key string) int64
	GetUint(key string) uint
	GetDuration(key string) time.Duration
	GetStringSlice(key string) []string
	GetObject(key string) fftypes.JSONObject
	GetObjectArray(key string) fftypes.JSONObjectArray
	Get(key string) interface{}
}

Prefix represents the global configuration, at a nested point in the config hierarchy. This allows plugins to define their Note that all values are GLOBAL so this cannot be used for per-instance customization. Rather for global initialization of plugins.

func NewPluginConfig

func NewPluginConfig(prefix string) Prefix

NewPluginConfig creates a new plugin configuration object, at the specified prefix

type PrefixArray

type PrefixArray interface {
	KeySet
	ArraySize() int
	ArrayEntry(i int) Prefix
}

PrefixArray represents an array of options at a particular layer in the config. This allows specifying the schema of keys that exist for every entry, and the defaults, as well as querying how many entries exist and generating a prefix for each entry (so that you can iterate).

type RootKey

type RootKey string

RootKey key are the known configuration keys

func AddRootKey

func AddRootKey(k string) RootKey

AddRootKey adds a root key, used to define the keys that are used within the core

Jump to

Keyboard shortcuts

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