Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChangeType ¶
type ChangeType uint8
const ( ChangeType_KV ChangeType = iota + 1 ChangeType_DIR )
type IChange ¶
type IChange interface { Topic() string Type() ChangeType }
type IObserver ¶
type IObserver interface { // Identity must keep unique in the server. Identity() string // Topics describes all topics those IObserver want to subscribe. Topics() []string // Inbound will receive all changes about topics. Inbound() chan<- IChange // Outbound will receive all changes about topics. Outbound() <-chan IChange // Close release observer resources, only be called IWatcher, importantly close channel. Close() }
IObserver describes all actions those the IWatcher's client should have.
type IWatcher ¶
type IWatcher interface { // Subscribe tell watcher there is a client want to get notified while topics are changed. Subscribe(obs ...IObserver) // Unsubscribe how to unsubscribe safely? Unsubscribe(obs IObserver) // ChangeNotify any changes would be sent to Watcher.Inbound. ChangeNotify(notify IChange) }
IWatcher provides Subscribe(obs ...IObserver) and Unsubscribe(obs IObserver) for observers, and ChangeNotify(notify IChange) for producer.
func NewChannelWatcher ¶
NewChannelWatcher construct a IWatcher at first call, if there is a IWatcher instance already, that instance would be returned at once.
Click to show internal directories.
Click to hide internal directories.