rainbond: github.com/goodrain/rainbond/util/watch Index | Files

package watch

import "github.com/goodrain/rainbond/util/watch"

Index

Package Files

api.go event.go interface.go util.go watch.go watcher.go

Constants

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

    DefaultChanSize int32 = 100
)

func ParseWatchResourceVersion Uses

func ParseWatchResourceVersion(resourceVersion string) (uint64, error)

ParseWatchResourceVersion ParseWatchResourceVersion

type Event Uses

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

Event represents a single event to a watched resource.

func (Event) GetKey Uses

func (e Event) GetKey() string

GetKey GetKey

func (Event) GetPreValue Uses

func (e Event) GetPreValue() []byte

GetPreValue GetPreValue

func (Event) GetPreValueString Uses

func (e Event) GetPreValueString() string

GetPreValueString GetPreValueString

func (Event) GetValue Uses

func (e Event) GetValue() []byte

GetValue GetValue

func (Event) GetValueString Uses

func (e Event) GetValueString() string

GetValueString GetValueString

type EventType Uses

type EventType string

EventType defines the possible types of events.

type Interface Uses

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 Uses

type Object interface {
}

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

type Status Uses

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 Uses

func (s Status) Error() string

type Watch Uses

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 Uses

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

New returns an etcd3 implementation of Watch.

func NewWithNoQuorumRead Uses

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

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

Package watch imports 11 packages (graph) and is imported by 4 packages. Updated 2018-10-27. Refresh now. Tools for package owners.