Documentation
¶
Index ¶
- type ConfigRegistry
- type Registry
- type RegistryConfigHelper
- func (h *RegistryConfigHelper) Apply() error
- func (h *RegistryConfigHelper) ClientCallback()
- func (h *RegistryConfigHelper) Close()
- func (h *RegistryConfigHelper) Load() error
- func (h *RegistryConfigHelper) Register(config Registry)
- func (h *RegistryConfigHelper) Save() error
- func (h *RegistryConfigHelper) SetClientCallback(cb func())
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfigRegistry ¶
type ConfigRegistry interface { // Register should register the given Registry to be load/save/apply Register(registry Registry) // Load should restore the configurations from the backing storage Load() error // Save should save the configurations to the backing storage Save() error // Apply should instruct each Registry to apply the configurations Apply() error // Close should instruct each Registry to close/clean up Close() // Set client callback SetClientCallback(cb func()) // Call client callback ClientCallback() }
ConfigRegistry defines an interface to save/load/apply configs in each Registry
func NewDryRegistryHelper ¶
func NewDryRegistryHelper() (ConfigRegistry, error)
NewDryRegistryHelper returns a helper to persist config to the Registry but without actual IO to save
func NewRegistryConfigHelper ¶
func NewRegistryConfigHelper() (ConfigRegistry, error)
NewRegistryConfigHelper returns a helper to persist config to the Registry
type Registry ¶
type Registry interface { // Name should return the name of the configuration Name() string // Value should return the values to be persisted in binary format Value() []byte // Load should load the binary returned by Value() and populate the configuration Load([]byte) error // Apply should re-apply configurations Apply() error // Close should handle graceful shutdown (e.g. closing sockets, etc) Close() error }
Registry provides an interface for different configurations to save to Registry and reload
type RegistryConfigHelper ¶
type RegistryConfigHelper struct {
// contains filtered or unexported fields
}
RegistryConfigHelper contains a list of configurations to be loaded, saved, and applied
func (*RegistryConfigHelper) Apply ¶
func (h *RegistryConfigHelper) Apply() error
Apply will apply each config accordingly. This is usually called after Load()
func (*RegistryConfigHelper) ClientCallback ¶
func (h *RegistryConfigHelper) ClientCallback()
func (*RegistryConfigHelper) Close ¶
func (h *RegistryConfigHelper) Close()
Close will release resources of each config
func (*RegistryConfigHelper) Load ¶
func (h *RegistryConfigHelper) Load() error
Load will retrive and populate configs from Registry
func (*RegistryConfigHelper) Register ¶
func (h *RegistryConfigHelper) Register(config Registry)
Register will add the config to the list
func (*RegistryConfigHelper) Save ¶
func (h *RegistryConfigHelper) Save() error
Save will persist all the configs to Registry as binary values
func (*RegistryConfigHelper) SetClientCallback ¶
func (h *RegistryConfigHelper) SetClientCallback(cb func())