Documentation ¶
Overview ¶
Package event provides the different Listeners
Index ¶
- Constants
- Variables
- type Dispatcher
- func (dis *Dispatcher) DispatchEvent(event *Event) error
- func (dis *Dispatcher) DispatchModuleEvent(events []*Event) error
- func (dis *Dispatcher) RegisterListener(listenerObj Listener, keys ...string) error
- func (dis *Dispatcher) RegisterModuleListener(listenerObj ModuleListener, modulePrefixes ...string) error
- func (dis *Dispatcher) UnRegisterListener(listenerObj Listener, keys ...string) error
- func (dis *Dispatcher) UnRegisterModuleListener(listenerObj ModuleListener, modulePrefixes ...string) error
- type Event
- type Listener
- type ModuleListener
- type PrefixIndex
Constants ¶
const ( Update = "UPDATE" Delete = "DELETE" Create = "CREATE" InvalidAction = "INVALID-ACTION" )
Event Constant
Variables ¶
var (
ErrNilListener = errors.New("nil listener")
)
errors
Functions ¶
This section is empty.
Types ¶
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher is the observer
func NewDispatcher ¶
func NewDispatcher() *Dispatcher
NewDispatcher is a new Dispatcher for listeners
func (*Dispatcher) DispatchEvent ¶
func (dis *Dispatcher) DispatchEvent(event *Event) error
DispatchEvent sends the action trigger for a particular event on a configuration
func (*Dispatcher) DispatchModuleEvent ¶ added in v1.3.0
func (dis *Dispatcher) DispatchModuleEvent(events []*Event) error
DispatchModuleEvent finds the registered function for callback according to the prefix of key in events
func (*Dispatcher) RegisterListener ¶
func (dis *Dispatcher) RegisterListener(listenerObj Listener, keys ...string) error
RegisterListener registers listener for particular configuration
func (*Dispatcher) RegisterModuleListener ¶ added in v1.3.0
func (dis *Dispatcher) RegisterModuleListener(listenerObj ModuleListener, modulePrefixes ...string) error
RegisterModuleListener registers moduleListener for particular configuration
func (*Dispatcher) UnRegisterListener ¶
func (dis *Dispatcher) UnRegisterListener(listenerObj Listener, keys ...string) error
UnRegisterListener un-register listener for a particular configuration
func (*Dispatcher) UnRegisterModuleListener ¶ added in v1.3.0
func (dis *Dispatcher) UnRegisterModuleListener(listenerObj ModuleListener, modulePrefixes ...string) error
UnRegisterModuleListener un-register moduleListener for a particular configuration
type Event ¶
type Event struct { EventSource string EventType string Key string Value interface{} HasUpdated bool }
Event generated when any config changes
type Listener ¶
type Listener interface {
Event(event *Event)
}
Listener All Listener should implement this Interface
type ModuleListener ¶ added in v1.3.0
type ModuleListener interface {
Event(event []*Event)
}
ModuleListener All moduleListener should implement this Interface
type PrefixIndex ¶ added in v1.5.0
type PrefixIndex struct { Prefix string NextParts map[string]*PrefixIndex }
func (*PrefixIndex) AddPrefix ¶ added in v1.5.0
func (pre *PrefixIndex) AddPrefix(prefix string)
func (*PrefixIndex) FindPrefix ¶ added in v1.5.0
func (pre *PrefixIndex) FindPrefix(key string) string
func (*PrefixIndex) RemovePrefix ¶ added in v1.5.0
func (pre *PrefixIndex) RemovePrefix(prefix string)