observer

package
v1.0.7 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseEvent

type BaseEvent struct {
	Source    interface{}
	Timestamp time.Time
}

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

func (b *BaseEvent) GetTimestamp() time.Time

GetTimestamp return the Timestamp when the event is created

func (*BaseEvent) String

func (b *BaseEvent) String() string

String return a human readable string representing this event

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 Event

type Event interface {
	fmt.Stringer
	GetSource() interface{}
	GetTimestamp() time.Time
}

Event is align with Event 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

Jump to

Keyboard shortcuts

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