watcher

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OPList means query a type list
	OPList = "LIST"
	// OPDelete means delete a type data
	OPDelete = "DELETE"
	// OPCreate means insert a type data
	OPCreate = "INSERT"
	// OPUpdate means update a type data
	OPUpdate = "UPDATE"
)

Variables

This section is empty.

Functions

func AddEvent

func AddEvent(obj interface{}, opType, channel string) error

AddEvent add the watching event into synchronizing list

Types

type Notification

type Notification struct {
	OPType  string `json:"op_type"`
	RawData string `json:"raw_data"`
}

Notification structure containing event notifications. OPType means the type of event, RawData means the object content of event

type NotifyInfo

type NotifyInfo struct {
	Notify      Notification
	ChannelName string
}

NotifyInfo stores a structure of a certain type

type NotifyWatcher

type NotifyWatcher struct {
	NotifyMsg chan *NotifyInfo
	// contains filtered or unexported fields
}

NotifyWatcher Event listening structure

func (*NotifyWatcher) Start

func (n *NotifyWatcher) Start() error

Start the synchronizing

func (*NotifyWatcher) StartProcessor

func (n *NotifyWatcher) StartProcessor() error

StartProcessor for the synchronizing, watch the events and process them

func (*NotifyWatcher) Stop

func (n *NotifyWatcher) Stop()

Stop the synchronize

func (*NotifyWatcher) Watch

func (n *NotifyWatcher) Watch(obj interface{}, channel string, processor Processor) error

Watch the events

type Processor

type Processor interface {
	List() ([]interface{}, error)
	Process(opType string, obj interface{})
}

Processor Provides interfaces for traversing events and determining event types

type Watcher

type Watcher interface {
	Watch(obj interface{}, channel string, processor Processor) error
	Stop()
	Start() error
	StartProcessor() error
}

Watcher provides an interface for monitoring and calling back events

func NewWatcher

func NewWatcher() Watcher

NewWatcher create a new NotifyWatcher

Jump to

Keyboard shortcuts

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