watch

package
v0.0.0-...-b479636 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2017 License: Apache-2.0 Imports: 4 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

This section is empty.

Types

type Event

type Event struct {
	Type EventType

	// Object is:
	//  * If Type is Added or Modified: the new state of the object.
	//  * If Type is Deleted: the state of the object immediately before deletion.
	//  * If Type is Error: *api.Status is recommended; other types may make sense
	//    depending on context.
	Object runtime.Object
}

Event represents a single event to a watched resource.

type EventType

type EventType string

EventType defines the possible types of events.

type FakeWatcher

type FakeWatcher struct {
	Stopped bool
	sync.Mutex
	// contains filtered or unexported fields
}

FakeWatcher lets you test anything that consumes a watch.Interface; threadsafe.

func NewFake

func NewFake() *FakeWatcher

func NewFakeWithChanSize

func NewFakeWithChanSize(size int, blocking bool) *FakeWatcher

func (*FakeWatcher) Action

func (f *FakeWatcher) Action(action EventType, obj runtime.Object)

Action sends an event of the requested type, for table-based testing.

func (*FakeWatcher) Add

func (f *FakeWatcher) Add(obj runtime.Object)

Add sends an add event.

func (*FakeWatcher) Delete

func (f *FakeWatcher) Delete(lastValue runtime.Object)

Delete sends a delete event.

func (*FakeWatcher) Error

func (f *FakeWatcher) Error(errValue runtime.Object)

Error sends an Error event.

func (*FakeWatcher) IsStopped

func (f *FakeWatcher) IsStopped() bool

func (*FakeWatcher) Modify

func (f *FakeWatcher) Modify(obj runtime.Object)

Modify sends a modify event.

func (*FakeWatcher) Reset

func (f *FakeWatcher) Reset()

Reset prepares the watcher to be reused.

func (*FakeWatcher) ResultChan

func (f *FakeWatcher) ResultChan() <-chan Event

func (*FakeWatcher) Stop

func (f *FakeWatcher) Stop()

Stop implements Interface.Stop().

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.

func NewEmptyWatch

func NewEmptyWatch() Interface

NewEmptyWatch returns a watch interface that returns no results and is closed. May be used in certain error conditions where no information is available but an error is not warranted.

type RaceFreeFakeWatcher

type RaceFreeFakeWatcher struct {
	Stopped bool
	sync.Mutex
	// contains filtered or unexported fields
}

RaceFreeFakeWatcher lets you test anything that consumes a watch.Interface; threadsafe.

func NewRaceFreeFake

func NewRaceFreeFake() *RaceFreeFakeWatcher

func (*RaceFreeFakeWatcher) Action

func (f *RaceFreeFakeWatcher) Action(action EventType, obj runtime.Object)

Action sends an event of the requested type, for table-based testing.

func (*RaceFreeFakeWatcher) Add

func (f *RaceFreeFakeWatcher) Add(obj runtime.Object)

Add sends an add event.

func (*RaceFreeFakeWatcher) Delete

func (f *RaceFreeFakeWatcher) Delete(lastValue runtime.Object)

Delete sends a delete event.

func (*RaceFreeFakeWatcher) Error

func (f *RaceFreeFakeWatcher) Error(errValue runtime.Object)

Error sends an Error event.

func (*RaceFreeFakeWatcher) IsStopped

func (f *RaceFreeFakeWatcher) IsStopped() bool

func (*RaceFreeFakeWatcher) Modify

func (f *RaceFreeFakeWatcher) Modify(obj runtime.Object)

Modify sends a modify event.

func (*RaceFreeFakeWatcher) Reset

func (f *RaceFreeFakeWatcher) Reset()

Reset prepares the watcher to be reused.

func (*RaceFreeFakeWatcher) ResultChan

func (f *RaceFreeFakeWatcher) ResultChan() <-chan Event

func (*RaceFreeFakeWatcher) Stop

func (f *RaceFreeFakeWatcher) Stop()

Stop implements Interface.Stop().

Jump to

Keyboard shortcuts

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