Documentation ¶
Index ¶
- Variables
- func GenerateConfigMarkdown(ctx context.Context, header string, keys []string) ([]byte, error)
- func Get(key RootKey) interface{}
- func GetBool(key RootKey) bool
- func GetByteSize(key RootKey) int64
- func GetConfig() fftypes.JSONObject
- func GetDuration(key RootKey) time.Duration
- func GetFloat64(key RootKey) float64
- func GetInt(key RootKey) int
- func GetInt64(key RootKey) int64
- func GetKnownKeys() []string
- func GetObject(key RootKey) fftypes.JSONObject
- func GetObjectArray(key RootKey) fftypes.JSONObjectArray
- func GetString(key RootKey) string
- func GetStringSlice(key RootKey) []string
- func GetUint(key RootKey) uint
- func GetUint64(key RootKey) uint64
- func IsSet(key RootKey) bool
- func MergeConfig(configRecords []*fftypes.ConfigRecord) error
- func ReadConfig(cfgSuffix, cfgFile string) error
- func RootConfigReset(setServiceDefaults ...func())
- func Set(key RootKey, value interface{})
- func SetupLogging(ctx context.Context)
- func ShowConfigCommand(initConf func() error) *cobra.Command
- func WatchConfig(ctx context.Context, onChange, onClose func()) error
- type ArraySection
- type KeySet
- type RootKey
- type Section
Constants ¶
This section is empty.
Variables ¶
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 GetConfig ¶
func GetConfig() fftypes.JSONObject
func GetDuration ¶
GetDuration gets a configuration time duration with consistent semantics
func GetObjectArray ¶
func GetObjectArray(key RootKey) fftypes.JSONObjectArray
GetObjectArray gets an array of configuration maps
func GetStringSlice ¶
GetStringSlice gets a configuration string array
func MergeConfig ¶
func MergeConfig(configRecords []*fftypes.ConfigRecord) error
func ReadConfig ¶
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 ShowConfigCommand ¶ added in v1.2.8
func WatchConfig ¶ added in v1.2.0
Listens for changes to the configuration file configured in Viper.
Types ¶
type ArraySection ¶ added in v0.1.4
type ArraySection interface { KeySet ArraySize() int ArrayEntry(i int) Section SubSection(name string) Section }
ArraySection 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 iterating through them.
func RootArray ¶ added in v0.1.4
func RootArray(prefix string) ArraySection
RootArray creates a new configuration array starting from the config root
type RootKey ¶
type RootKey string
RootKey key are the known configuration keys
func AddRootKey ¶
AddRootKey adds a root key, used to define the keys that are used within the core
type Section ¶ added in v0.1.4
type Section interface { KeySet SetDefault(key string, defValue interface{}) SubSection(name string) Section SubArray(name string) ArraySection Set(key string, value interface{}) IsSet(key string) bool Resolve(key string) string GetString(key string) string GetBool(key string) bool GetInt(key string) int GetInt64(key string) int64 GetFloat64(key string) float64 GetByteSize(key string) int64 GetUint(key string) uint GetUint64(key string) uint64 GetDuration(key string) time.Duration GetStringSlice(key string) []string GetObject(key string) fftypes.JSONObject GetObjectArray(key string) fftypes.JSONObjectArray Get(key string) interface{} }
Section represents a section of the global configuration, at a nested point in the config hierarchy. Note that all keys are added to a GLOBAL map, so this cannot be used for per-instance customization.
func RootSection ¶ added in v0.1.4
RootSection creates a new configuration section starting from the config root