watch

package
v1.19.1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Type EventType   `json:"type"`
	Data meta.Object `json:"data"`
}

Event holding event info for data object

type EventType

type EventType string

EventType definition for watch

const (
	//EventSync sync event, reserved for force synchronization
	EventSync EventType = "SYNC"
	//EventAdded add event
	EventAdded EventType = "ADDED"
	//EventUpdated updated/modified event
	EventUpdated EventType = "UPDATED"
	//EventDeleted deleted event
	EventDeleted EventType = "DELETED"
	//EventErr error event for watch, error occured, but watch still works
	EventErr EventType = "ERROR"
	//DefaultChannelBuffer buffer for watch event channel
	DefaultChannelBuffer = 128
)

type Interface

type Interface interface {
	//stop watch channel
	Stop()
	//get watch events, if watch stopped/error, watch must close
	// channel and exit, watch user must read channel like
	// e, ok := <-channel
	WatchEvent() <-chan Event
}

Interface define watch channel

func NewSelectWatch

func NewSelectWatch(w Interface, fn SelectFunc) Interface

NewSelectWatch wrap watcher with filter func

type SelectFunc

type SelectFunc func(meta.Object) (bool, error)

SelectFunc custom function to verify how filter acts

type SelectorWatch

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

SelectorWatch watcher wraper offer filter function to filter data object if needed

func (*SelectorWatch) Stop

func (fw *SelectorWatch) Stop()

Stop stop watch channel

func (*SelectorWatch) WatchEvent

func (fw *SelectorWatch) WatchEvent() <-chan Event

WatchEvent get watch events

Jump to

Keyboard shortcuts

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