watcher

package
v0.0.0-...-cb472e6 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NoEventsError               = errors.New(noEventWarning)
	HeadNodeNotExistError       = errors.New(headNodeNotExistError)
	TailNodeNotExistError       = errors.New(tailNodeNotExistError)
	TailNodeTargetNotExistError = errors.New(tailNodeTargetNotExistError)
	StartCursorNotExistError    = errors.New(startCursorNotExistError)
)

Functions

This section is empty.

Types

type Watcher

type Watcher struct {
	// contains filtered or unexported fields
}

Watcher is resource events watcher in eventserver.

func NewWatcher

func NewWatcher(ctx context.Context, cache *redis.Client) *Watcher

NewWatcher creates a new Watcher object.

func (*Watcher) GetEventDetailsWithCursorNodes

func (w *Watcher) GetEventDetailsWithCursorNodes(hitNodes []*watch.ChainNode, key event.Key) ([]string, error)

GetEventDetailsWithCursorNodes gets event detail strings base on target hit chain nodes.

func (*Watcher) GetEventsWithCursorNodes

func (w *Watcher) GetEventsWithCursorNodes(opts *watch.WatchEventOptions, hitNodes []*watch.ChainNode,
	key event.Key, rid string) ([]*watch.WatchEventDetail, error)

func (*Watcher) GetHeadTailNodeTargetNode

func (w *Watcher) GetHeadTailNodeTargetNode(key event.Key) (*watch.ChainNode, *watch.ChainNode, error)

func (*Watcher) GetHitNodeWithEventType

func (w *Watcher) GetHitNodeWithEventType(nodes []*watch.ChainNode, typs []watch.EventType) []*watch.ChainNode

func (*Watcher) GetLatestEventDetail

func (w *Watcher) GetLatestEventDetail(key event.Key) (node *watch.ChainNode, detail string, err error)

func (*Watcher) GetNodesFromCursor

func (w *Watcher) GetNodesFromCursor(count int, startCursor string, key event.Key) ([]*watch.ChainNode, error)

GetNodesFromCursor get node start from a cursor, the return result do not contain this cursor's value.

func (*Watcher) WatchFromNow

func (w *Watcher) WatchFromNow(key event.Key, opts *watch.WatchEventOptions, rid string) (*watch.WatchEventDetail, error)

WatchFromNow watches target resource events from now.

func (*Watcher) WatchWithCursor

func (w *Watcher) WatchWithCursor(key event.Key, opts *watch.WatchEventOptions, rid string) ([]*watch.WatchEventDetail, error)

watchWithCursor get events with the start cursor which is offered by user. it will hold the request for timeout seconds if no matched event is hit. if event has been hit in a round, then events will be returned immediately. if no events hit, then will loop the event every 200ms until timeout and return with a special cursor named "NoEventCursor", then we will help the user watch event from the head cursor.

func (*Watcher) WatchWithStartFrom

func (w *Watcher) WatchWithStartFrom(key event.Key, opts *watch.WatchEventOptions, rid string) ([]*watch.WatchEventDetail, error)

WatchWithStartFrom watches target resource base on timestamp.

Jump to

Keyboard shortcuts

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