Documentation ¶
Index ¶
- type BaseEvent
- type BaseListener
- func (bl *BaseListener) AddEventListener(listener EventListener)
- func (bl *BaseListener) AddEventListeners(listenersSlice []EventListener)
- func (bl *BaseListener) GetAllEventListeners() []EventListener
- func (bl *BaseListener) RemoveAllEventListeners()
- func (bl *BaseListener) RemoveEventListener(listener EventListener)
- func (bl *BaseListener) RemoveEventListeners(listenersSlice []EventListener)
- type ChangedNotify
- type ConditionalEventListener
- type Event
- type EventDispatcher
- type EventListener
- type Listenable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseEvent ¶
BaseEvent is the base implementation of Event You should never use it directly
func NewBaseEvent ¶
func NewBaseEvent(source interface{}) *BaseEvent
NewBaseEvent create an BaseEvent instance and the Timestamp will be current timestamp
func (*BaseEvent) GetSource ¶
func (b *BaseEvent) GetSource() interface{}
GetSource return the source
func (*BaseEvent) GetTimestamp ¶
GetTimestamp return the Timestamp when the event is created
type BaseListener ¶
type BaseListener struct { Listenable ListenersCache map[reflect.Type][]EventListener Mutex sync.RWMutex }
BaseListener base listenable
func NewBaseListener ¶
func NewBaseListener() BaseListener
NewBaseListener a constructor of base listenable
func (*BaseListener) AddEventListener ¶
func (bl *BaseListener) AddEventListener(listener EventListener)
AddEventListener add event listener
func (*BaseListener) AddEventListeners ¶
func (bl *BaseListener) AddEventListeners(listenersSlice []EventListener)
AddEventListeners add the slice of event listener
func (*BaseListener) GetAllEventListeners ¶
func (bl *BaseListener) GetAllEventListeners() []EventListener
GetAllEventListeners get all listener using RLock
func (*BaseListener) RemoveAllEventListeners ¶
func (bl *BaseListener) RemoveAllEventListeners()
RemoveAllEventListeners remove all using Lock
func (*BaseListener) RemoveEventListener ¶
func (bl *BaseListener) RemoveEventListener(listener EventListener)
RemoveEventListener remove the event listener
func (*BaseListener) RemoveEventListeners ¶
func (bl *BaseListener) RemoveEventListeners(listenersSlice []EventListener)
RemoveEventListeners remove the slice of event listener it will iterate all listener and remove it one by one
type ChangedNotify ¶
type ChangedNotify interface {
Notify(e Event)
}
type ConditionalEventListener ¶
type ConditionalEventListener interface { EventListener // Accept will make the decision whether it should handle this event Accept(e Event) bool }
ConditionalEventListener only handle the event which it can handle
type EventDispatcher ¶
type EventDispatcher interface { Listenable // Dispatch event Dispatch(event Event) }
EventDispatcher is align with EventDispatcher interface in Java. it's the top abstraction Align with 2.7.5
type EventListener ¶
type EventListener interface { gxsort.Prioritizer // OnEvent handle this event OnEvent(e Event) error // GetEventType listen which event type GetEventType() reflect.Type }
EventListener is an new interface used to align with dubbo 2.7.5 It contains the Prioritized means that the listener has its priority Usually the priority of your custom implementation should be between [100, 9000] the number outside the range will be though as system reserve number usually implementation should be singleton
type Listenable ¶
type Listenable interface { AddEventListener(listener EventListener) AddEventListeners(listenersSlice []EventListener) RemoveEventListener(listener EventListener) RemoveEventListeners(listenersSlice []EventListener) GetAllEventListeners() []EventListener RemoveAllEventListeners() }
Listenable could add and remove the event listener