event

package
v1.5.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 2, 2022 License: Apache-2.0 Imports: 5 Imported by: 10

Documentation

Overview

Package event provides the different Listeners

Index

Constants

View Source
const (
	Update        = "UPDATE"
	Delete        = "DELETE"
	Create        = "CREATE"
	InvalidAction = "INVALID-ACTION"
)

Event Constant

Variables

View Source
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

func PopulateEvents added in v1.2.0

func PopulateEvents(sourceName string, currentConfig, updatedConfig map[string]interface{}) ([]*Event, error)

PopulateEvents compare old and new configurations to generate events that need to be updated

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)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL