Documentation ¶
Overview ¶
Package process_settings implements dynamic settings for the process.
Index ¶
- func CancelWhenUpdated(index int) error
- func Get(settingPath ...string) (interface{}, error)
- func SafeGet(settingPath ...string) (interface{}, error)
- func SetGlobalProcessSettings(settings *ProcessSettings)
- func WhenUpdated(fn func(), initial_update ...bool) (int, error)
- type ProcessSettings
- func (ps *ProcessSettings) CancelWhenUpdated(index int)
- func (ps *ProcessSettings) Get(settingPath ...string) (interface{}, error)
- func (ps *ProcessSettings) SafeGet(settingPath ...string) (interface{}, error)
- func (ps *ProcessSettings) StartMonitor()
- func (ps *ProcessSettings) WhenUpdated(fn func(), initial_update ...bool) int
- type SettingNotFound
- type SettingsFile
- type SettingsMetadata
- type TargetEvaluator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CancelWhenUpdated ¶
CancelWhenUpdated cancels a function that was registered on the global ProcessSettings instance using WhenUpdated. If the global instance has not been set, an error is returned.
func Get ¶
Get returns the value of a setting based on the current targeting. If the global instance has not been set, or the requested setting is not found, an error is returned.
func SafeGet ¶
SafeGet returns the value of a setting based on the current targeting. If the global instance has not been set, or the requested setting is not found, nil is returned.
func SetGlobalProcessSettings ¶
func SetGlobalProcessSettings(settings *ProcessSettings)
SetGlobalProcessSettings sets the global process settings instance to be used by the rest of the process.
func WhenUpdated ¶
WhenUpdated registers a function to be called when the settings are updated on the global ProcessSettings instance. If the global instance has not been set, an error is returned.
Types ¶
type ProcessSettings ¶
type ProcessSettings struct { FilePath string // The path to the settings file that was used to create the ProcessSettings Settings *[]SettingsFile // The settings files that make up the ProcessSettings TargetEvaluator TargetEvaluator // The target evaluator that is used to determine which settings files are applicable Monitor *fsnotify.Watcher // The file monitor that is used to detect changes to the settings file WhenUpdatedRegistry []func() // A list of functions to call when the settings are updated }
A ProcessSettings is a collection of settings files and a target evaluator that can be used to get the value of a settings based on the current targeting.
func NewProcessSettingsFromFile ¶
func NewProcessSettingsFromFile(filePath string, staticContext map[string]interface{}) (*ProcessSettings, error)
NewProcessSettingsFromFile creates a new instance of ProcessSettings by loading the settings from a specified file path and using the specified static context to evaluate the targeting.
func (*ProcessSettings) CancelWhenUpdated ¶
func (ps *ProcessSettings) CancelWhenUpdated(index int)
CancelWhenUpdated cancels a function that was registered using WhenUpdated.
func (*ProcessSettings) Get ¶
func (ps *ProcessSettings) Get(settingPath ...string) (interface{}, error)
Get returns the value of a setting based on the current targeting. If the requested setting is not found, an error is returned.
func (*ProcessSettings) SafeGet ¶
func (ps *ProcessSettings) SafeGet(settingPath ...string) (interface{}, error)
SafeGet returns the value of a setting based on the current targeting. If the requested setting is not found, nil is returned.
func (*ProcessSettings) StartMonitor ¶
func (ps *ProcessSettings) StartMonitor()
StartMonitor starts a goroutine that monitors the settings file for changes
func (*ProcessSettings) WhenUpdated ¶
func (ps *ProcessSettings) WhenUpdated(fn func(), initial_update ...bool) int
WhenUpdated registers a function to be called when the settings are updated and by default calls the function immediately. Optionally false can be passed as the second argument to not call the function immediately. The function returns an index that can be used to cancel the function using CancelWhenUpdated.
type SettingNotFound ¶
type SettingNotFound struct {
SettingPath []string
}
func (*SettingNotFound) Error ¶
func (e *SettingNotFound) Error() string
type SettingsFile ¶
type SettingsFile struct { FileName string `yaml:"filename"` Target map[string]interface{} `yaml:"target"` Settings map[string]interface{} `yaml:"settings"` Metadata SettingsMetadata `yaml:"meta"` }
type SettingsMetadata ¶
type TargetEvaluator ¶
type TargetEvaluator struct {
// contains filtered or unexported fields
}