watch

package
v5.1.4-release+incompa... Latest Latest
Warning

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

Go to latest
Published: May 17, 2019 License: LGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Added    EventType = "ADDED"
	Modified EventType = "MODIFIED"
	Deleted  EventType = "DELETED"
	Error    EventType = "ERROR"

	DefaultChanSize int32 = 100
)

Variables

This section is empty.

Functions

func ParseWatchResourceVersion

func ParseWatchResourceVersion(resourceVersion string) (uint64, error)

ParseWatchResourceVersion ParseWatchResourceVersion

Types

type Event

type Event struct {
	Type   EventType
	Source *event
	Error  Status
}

Event represents a single event to a watched resource.

func (Event) GetKey

func (e Event) GetKey() string

GetKey GetKey

func (Event) GetPreValue

func (e Event) GetPreValue() []byte

GetPreValue GetPreValue

func (Event) GetPreValueString

func (e Event) GetPreValueString() string

GetPreValueString GetPreValueString

func (Event) GetValue

func (e Event) GetValue() []byte

GetValue GetValue

func (Event) GetValueString

func (e Event) GetValueString() string

GetValueString GetValueString

type EventType

type EventType string

EventType defines the possible types of events.

type Interface

type Interface interface {
	// Stops watching. Will close the channel returned by ResultChan(). Releases
	// any resources used by the watch.
	Stop()

	// Returns a chan which will receive all the events. If an error occurs
	// or Stop() is called, this channel will be closed, in which case the
	// watch should be completely cleaned up.
	ResultChan() <-chan Event
}

Interface can be implemented by anything that knows how to watch and report changes.

type Object

type Object interface {
}

Object All Watcher types registered with Scheme must support the Object interface.

type Status

type Status struct {
	// Status of the operation.
	// One of: "Success" or "Failure".
	// +optional
	Status string `json:"status,omitempty"`
	// A human-readable description of the status of this operation.
	// +optional
	Message string `json:"message,omitempty"`
	// A machine-readable description of why this operation is in the
	// "Failure" status. If this value is empty there
	// is no information available. A Reason clarifies an HTTP status
	// code but does not override it.
	// +optional
	Reason string `json:"reason,omitempty"`
	// Extended data associated with the reason.  Each reason may define its
	// own extended details. This field is optional and the data returned
	// is not guaranteed to conform to any schema except that defined by
	// the reason type.
	// +optional
	Details *string `json:"details,omitempty" `
	// Suggested HTTP return code for this status, 0 if not set.
	// +optional
	Code int32 `json:"code,omitempty"`
}

Status is a return value for calls that don't return other objects.

func (Status) Error

func (s Status) Error() string

type Watch

type Watch interface {
	// Watch begins watching the specified key. Events are decoded into API objects,
	// and any items selected by 'p' are sent down to returned watch.Interface.
	// resourceVersion may be used to specify what version to begin watching,
	// which should be the current resourceVersion, and no longer rv+1
	// (e.g. reconnecting without missing any updates).
	// If resource version is "0", this interface will get current object at given key
	// and send it in an "ADDED" event, before watch starts.
	Watch(ctx context.Context, key string, resourceVersion string) (Interface, error)

	// WatchList begins watching the specified key's items. Items are decoded into API
	// objects and any item selected by 'p' are sent down to returned watch.Interface.
	// resourceVersion may be used to specify what version to begin watching,
	// which should be the current resourceVersion, and no longer rv+1
	// (e.g. reconnecting without missing any updates).
	// If resource version is "0", this interface will list current objects directory defined by key
	// and send them in "ADDED" events, before watch starts.
	WatchList(ctx context.Context, key string, resourceVersion string) (Interface, error)
}

Watch offers a common interface for object marshaling/unmarshaling operations and hides all the storage-related operations behind it.

func New

func New(c *clientv3.Client, prefix string) Watch

New returns an etcd3 implementation of Watch.

func NewWithNoQuorumRead

func NewWithNoQuorumRead(c *clientv3.Client, prefix string) Watch

NewWithNoQuorumRead returns etcd3 implementation of storage.Interface where Get operations don't require quorum read.

Jump to

Keyboard shortcuts

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