Documentation ¶
Index ¶
- func EventTypeStrings() []string
- func NewFxDriver(statusRegistry status.Registry, prometheusRegistry *prometheus.Registry, ...) (*fxDriver, error)
- func NewKeyBase(key Key) *keyBase
- func NewPrefixBase(prefix string) *prefixBase
- func NewUnmarshalKeyNotifier(key Key, unmarshaller config.Unmarshaller, ...) (*unmarshalKeyNotifier, error)
- func NewUnmarshalPrefixNotifier(prefix string, unmarshalNotifyFunc UnmarshalNotifyFunc, ...) (*unmarshalPrefixNotifier, error)
- func WatcherLifecycle(lc fx.Lifecycle, watcher Watcher, notifiers []PrefixNotifier)
- type BasicKeyNotifier
- type DefaultTrackers
- func (t *DefaultTrackers) AddKeyNotifier(notifier KeyNotifier) error
- func (t *DefaultTrackers) AddPrefixNotifier(notifier PrefixNotifier) error
- 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) UpdateValue(key Key, updateFunc UpdateValueFunc)
- func (t *DefaultTrackers) WriteEvent(key Key, value []byte)
- type Event
- type EventType
- type EventWriter
- type FxOptionsFunc
- type GetUnmarshallerFunc
- type Key
- type KeyBase
- type KeyNotifier
- type NotifyFunc
- type PrefixBase
- type PrefixNotifier
- type Trackers
- type TrackersConstructor
- type TransformFunc
- type UnmarshalNotifyFunc
- type UpdateValueFunc
- 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 NewFxDriver ¶
func NewFxDriver( statusRegistry status.Registry, prometheusRegistry *prometheus.Registry, getUnmarshallerFunc GetUnmarshallerFunc, fxOptionsFuncs []FxOptionsFunc, ) (*fxDriver, error)
NewFxDriver creates a new FxDriver.
func NewPrefixBase ¶
func NewPrefixBase(prefix string) *prefixBase
NewPrefixBase creates a new prefix notifier.
func NewUnmarshalKeyNotifier ¶
func NewUnmarshalKeyNotifier(key Key, unmarshaller config.Unmarshaller, unmarshalNotifyFunc UnmarshalNotifyFunc, ) (*unmarshalKeyNotifier, error)
NewUnmarshalKeyNotifier creates a new instance of ConfigKeyNotifier.
func NewUnmarshalPrefixNotifier ¶
func NewUnmarshalPrefixNotifier(prefix string, unmarshalNotifyFunc UnmarshalNotifyFunc, getUnmarshallerFunc GetUnmarshallerFunc, ) (*unmarshalPrefixNotifier, error)
NewUnmarshalPrefixNotifier returns a new instance of UnmarshalPrefixNotifier.
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 KeyBase }
BasicKeyNotifier holds fields for basic key notifier.
func NewBasicKeyNotifier ¶
func NewBasicKeyNotifier(key Key, notifyFunc NotifyFunc) *BasicKeyNotifier
NewBasicKeyNotifier returns a new basic key notifier.
func (*BasicKeyNotifier) Notify ¶
func (bfn *BasicKeyNotifier) Notify(event Event)
Notify calls the registered notifier function with the given event.
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) 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) UpdateValue ¶
func (t *DefaultTrackers) UpdateValue(key Key, updateFunc UpdateValueFunc)
UpdateValue returns the current value tracked by a key.
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 EventWriter ¶
type EventWriter interface { WriteEvent(key Key, value []byte) RemoveEvent(key Key) Purge(prefix string) UpdateValue(key Key, updateFunc UpdateValueFunc) }
EventWriter can be used to inject events into a tracker collection.
func NewPrefixedEventWriter ¶
func NewPrefixedEventWriter(prefix string, ew EventWriter) EventWriter
NewPrefixedEventWriter returns an event writer which keys will be automatically prefixed with given prefix.
It's recommended that prefix ends up some kind of delimiter, like `.` or `/`.
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 KeyBase ¶
type KeyBase interface { GetKey() Key // contains filtered or unexported methods }
KeyBase is interface for key.
type KeyNotifier ¶
KeyNotifier is the interface that all key notifiers must implement.
type NotifyFunc ¶
type NotifyFunc func(Event)
NotifyFunc is a signature for basic notifier function.
type PrefixBase ¶
type PrefixBase interface { GetPrefix() string // contains filtered or unexported methods }
PrefixBase is the base type for all prefix notifiers.
type PrefixNotifier ¶
type PrefixNotifier interface { PrefixBase GetKeyNotifier(key Key) (KeyNotifier, error) }
PrefixNotifier is the interface that all prefix notifiers must implement.
func NewBasicPrefixNotifier ¶
func NewBasicPrefixNotifier(prefix string, notifyFunc NotifyFunc) PrefixNotifier
NewBasicPrefixNotifier returns a new basic prefix notifier.
type Trackers ¶
type Trackers interface { Watcher EventWriter }
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 UnmarshalNotifyFunc ¶
type UnmarshalNotifyFunc func(Event, config.Unmarshaller)
UnmarshalNotifyFunc is a function that is called when a config key is written.
type UpdateValueFunc ¶
UpdateValueFunc is a function that can be used to update the value of an existing tracker entry.
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.