Documentation ¶
Index ¶
- func EventTypeStrings() []string
- func NotifierLifecycle(lc fx.Lifecycle, watcher Watcher, notifier PrefixNotifier)
- func WatcherLifecycle(lc fx.Lifecycle, watcher Watcher, notifiers []PrefixNotifier)
- type BasicKeyNotifier
- type BasicPrefixNotifier
- type DefaultTrackers
- func (t *DefaultTrackers) AddKeyNotifier(notifier KeyNotifier) error
- func (t *DefaultTrackers) AddPrefixNotifier(notifier PrefixNotifier) error
- func (t *DefaultTrackers) GetCurrentValue(key Key) []byte
- func (t *DefaultTrackers) Purge(prefix string)
- func (t *DefaultTrackers) RemoveEvent(key Key)
- func (t *DefaultTrackers) RemoveKeyNotifier(notifier KeyNotifier) error
- func (t *DefaultTrackers) RemovePrefixNotifier(notifier PrefixNotifier) error
- func (t *DefaultTrackers) Start() error
- func (t *DefaultTrackers) Stop() error
- func (t *DefaultTrackers) WriteEvent(key Key, value []byte)
- type Event
- type EventType
- type FxDriver
- type FxOptionsFunc
- type GetUnmarshallerFunc
- type Key
- type KeyNotifier
- type KeyNotifierBase
- type NotifierBase
- type NotifyFunc
- type PrefixNotifier
- type PrefixNotifierBase
- type Trackers
- type TrackersConstructor
- type TransformFunc
- type UnmarshalKeyNotifier
- type UnmarshalNotifyFunc
- type UnmarshalPrefixNotifier
- type Watcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EventTypeStrings ¶
func EventTypeStrings() []string
EventTypeStrings returns a slice of all String values of the enum
func NotifierLifecycle ¶
func NotifierLifecycle(lc fx.Lifecycle, watcher Watcher, notifier PrefixNotifier)
NotifierLifecycle adds/removed prefix notifier to etcd watcher.
func WatcherLifecycle ¶
func WatcherLifecycle(lc fx.Lifecycle, watcher Watcher, notifiers []PrefixNotifier)
WatcherLifecycle starts/stops watcher and adds/removes prefix notifier(s) to etcd watcher.
Types ¶
type BasicKeyNotifier ¶
type BasicKeyNotifier struct { NotifyFunc NotifyFunc KeyNotifierBase }
BasicKeyNotifier holds fields for basic key notifier.
func (*BasicKeyNotifier) Notify ¶
func (bfn *BasicKeyNotifier) Notify(event Event)
Notify calls the registered notifier function with the given event.
type BasicPrefixNotifier ¶
type BasicPrefixNotifier struct { NotifyFunc NotifyFunc PrefixNotifierBase }
BasicPrefixNotifier holds fields for basic prefix notifier.
func (*BasicPrefixNotifier) GetKeyNotifier ¶
func (bdn *BasicPrefixNotifier) GetKeyNotifier(key Key) KeyNotifier
GetKeyNotifier returns a basic key notifier for the given key.
type DefaultTrackers ¶
type DefaultTrackers struct {
// contains filtered or unexported fields
}
DefaultTrackers is a collection of key trackers.
func NewDefaultTrackers ¶
func NewDefaultTrackers() *DefaultTrackers
NewDefaultTrackers creates a new instance of Trackers.
func (*DefaultTrackers) AddKeyNotifier ¶
func (t *DefaultTrackers) AddKeyNotifier(notifier KeyNotifier) error
AddKeyNotifier is a convenience function to add a key notifier to the underlying trackers. If the key of the given notifier is already tracked, the notifier will be added to the existing tracker.
func (*DefaultTrackers) AddPrefixNotifier ¶
func (t *DefaultTrackers) AddPrefixNotifier(notifier PrefixNotifier) error
AddPrefixNotifier is a convenience function to add a prefix notifier to the underlying trackers. Internally, a key notifier is added for each key under the given prefix. If the prefix of the given notifier is already tracked, the notifier will be added to the existing tracker.
func (*DefaultTrackers) GetCurrentValue ¶
func (t *DefaultTrackers) GetCurrentValue(key Key) []byte
GetCurrentValue returns the current value tracked by a key.
func (*DefaultTrackers) Purge ¶
func (t *DefaultTrackers) Purge(prefix string)
Purge is a convenience function to purge all trackers. This will remove all key notifiers and prefix notifiers.
func (*DefaultTrackers) RemoveEvent ¶
func (t *DefaultTrackers) RemoveEvent(key Key)
RemoveEvent sends a Remove event with the given key and value to the underlying event channel.
func (*DefaultTrackers) RemoveKeyNotifier ¶
func (t *DefaultTrackers) RemoveKeyNotifier(notifier KeyNotifier) error
RemoveKeyNotifier is a convenience function to remove a key notifier from the underlying trackers. If the key of the given notifier is not tracked, the notifier will be ignored.
func (*DefaultTrackers) RemovePrefixNotifier ¶
func (t *DefaultTrackers) RemovePrefixNotifier(notifier PrefixNotifier) error
RemovePrefixNotifier is a convenience function to remove a prefix notifier from the underlying trackers. Internally, a key notifier is removed for each key under the given prefix. If the prefix of the given notifier is not tracked, the notifier will be ignored.
func (*DefaultTrackers) Start ¶
func (t *DefaultTrackers) Start() error
Start opens the underlying event channel and starts the event loop. See AddKeyNotifier, AddPrefixNotifier, RemoveKeyNotifier, RemovePrefixNotifier, and Purge for more information.
func (*DefaultTrackers) Stop ¶
func (t *DefaultTrackers) Stop() error
Stop closes all channels and waits for the goroutine to finish.
func (*DefaultTrackers) WriteEvent ¶
func (t *DefaultTrackers) WriteEvent(key Key, value []byte)
WriteEvent sends a Write event with the given key and value to the underlying event channel.
type EventType ¶
type EventType uint8
EventType is the type of event.
const ( // Write represents that the watched entity has been written to. // In case of a file, it could have been created, modified, or symlinked. // In case of an etcd entry, it could have been added or updated. Write EventType = 1 << iota // Remove represents that the watched entity has been removed. Remove )
func EventTypeString ¶
EventTypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
func EventTypeValues ¶
func EventTypeValues() []EventType
EventTypeValues returns all values of the enum
func (EventType) IsAEventType ¶
IsAEventType returns "true" if the value is listed in the enum definition. "false" otherwise
type FxDriver ¶
type FxDriver struct { // Options for new unmarshaller instances UnmarshalPrefixNotifier // function to provide fx.Options. // // Resulting fx.Options will be used to create a "mini FX-based apps" per key. // The lifecycle of the app will be tied to the existence of the key. // Note that when key's contents change the previous App will be stopped // and a fresh one will be created. FxOptionsFuncs []FxOptionsFunc StatusRegistry status.Registry PrometheusRegistry *prometheus.Registry }
FxDriver tracks prefix and allows spawning "mini FX-based apps" per key in the prefix.
func (*FxDriver) GetKeyNotifier ¶
func (fxDriver *FxDriver) GetKeyNotifier(key Key) KeyNotifier
GetKeyNotifier returns a KeyNotifier that will notify the driver of key changes.
type FxOptionsFunc ¶
FxOptionsFunc is a function that returns fx.Option.
type GetUnmarshallerFunc ¶
type GetUnmarshallerFunc func(bytes []byte) (config.Unmarshaller, error)
GetUnmarshallerFunc is a function that is called to create a new unmarshaller.
type KeyNotifier ¶
type KeyNotifier interface { GetKey() Key SetKey(Key) Notify(Event) // contains filtered or unexported methods }
KeyNotifier is the interface that all key notifiers must implement.
type KeyNotifierBase ¶
type KeyNotifierBase struct { NotifierBase // contains filtered or unexported fields }
KeyNotifierBase is the base type for all key notifiers.
type NotifierBase ¶
type NotifierBase struct {
// contains filtered or unexported fields
}
NotifierBase is the base type for all notifiers.
func (*NotifierBase) GetTransformFunc ¶
func (idb *NotifierBase) GetTransformFunc() TransformFunc
GetTransformFunc returns the transform function.
func (*NotifierBase) SetTransformFunc ¶
func (idb *NotifierBase) SetTransformFunc(tf TransformFunc)
SetTransformFunc sets the transform function.
type NotifyFunc ¶
type NotifyFunc func(Event)
NotifyFunc is a signature for basic notifier function.
type PrefixNotifier ¶
type PrefixNotifier interface { GetPrefix() string GetKeyNotifier(key Key) KeyNotifier // contains filtered or unexported methods }
PrefixNotifier is the interface that all prefix notifiers must implement.
type PrefixNotifierBase ¶
type PrefixNotifierBase struct { NotifierBase Prefix string }
PrefixNotifierBase is the base type for all prefix notifiers.
func (*PrefixNotifierBase) GetPrefix ¶
func (pnb *PrefixNotifierBase) GetPrefix() string
GetPrefix returns the prefix.
type Trackers ¶
type Trackers interface { Watcher WriteEvent(key Key, value []byte) RemoveEvent(key Key) GetCurrentValue(key Key) []byte Purge(prefix string) }
Trackers is the interface of a tracker collection.
type TrackersConstructor ¶
type TrackersConstructor struct {
Name string
}
TrackersConstructor is a Fx constructor for Trackers.
func (TrackersConstructor) Annotate ¶
func (t TrackersConstructor) Annotate() fx.Option
Annotate provides Fx annotated Tracker.
type TransformFunc ¶
TransformFunc is the callback signature that other notifiers (like NewPrefixToEtcdNotifier and NewKeyToEtcdNotifier) can use to receive notification before contents are processed. This function can transform the key and contents before processing them further.
type UnmarshalKeyNotifier ¶
type UnmarshalKeyNotifier struct { Unmarshaller config.Unmarshaller UnmarshalNotifyFunc UnmarshalNotifyFunc KeyNotifierBase // contains filtered or unexported fields }
UnmarshalKeyNotifier holds the state of a key notifier that updates config at a key using the provided unmarshaller.
func NewUnmarshalKeyNotifier ¶
func NewUnmarshalKeyNotifier(key Key, unmarshaller config.Unmarshaller, unmarshalNotifyFunc UnmarshalNotifyFunc) *UnmarshalKeyNotifier
NewUnmarshalKeyNotifier creates a new instance of ConfigKeyNotifier.
func (*UnmarshalKeyNotifier) Notify ¶
func (cfn *UnmarshalKeyNotifier) Notify(event Event)
Notify provides an unmarshaller based on received event. It reloads the the bytes into unmarshaller before invoking callback.
type UnmarshalNotifyFunc ¶
type UnmarshalNotifyFunc func(Event, config.Unmarshaller)
UnmarshalNotifyFunc is a function that is called when a config key is written.
type UnmarshalPrefixNotifier ¶
type UnmarshalPrefixNotifier struct { UnmarshalNotifyFunc UnmarshalNotifyFunc GetUnmarshallerFunc GetUnmarshallerFunc PrefixNotifierBase }
UnmarshalPrefixNotifier holds the state of a prefix notifier that updates config at a prefix using the provided unmarshaller.
func (*UnmarshalPrefixNotifier) GetKeyNotifier ¶
func (cdn *UnmarshalPrefixNotifier) GetKeyNotifier(key Key) KeyNotifier
GetKeyNotifier returns a new key notifier for the given key.
type Watcher ¶
type Watcher interface { AddPrefixNotifier(PrefixNotifier) error RemovePrefixNotifier(PrefixNotifier) error AddKeyNotifier(KeyNotifier) error RemoveKeyNotifier(KeyNotifier) error Start() error Stop() error }
Watcher is a generic interface for watchers/trackers.