wait

package
v0.0.0-...-8b7d7e7 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTestServiceWithConditions

func CreateTestServiceWithConditions(
	name string,
	readyStatus, otherReadyStatus corev1.ConditionStatus,
	reason, message string,
	generations ...int64,
) *servingv1.Service

CreateTestServiceWithConditions create a service skeleton with a given ConditionReady status and all other statuses set to otherReadyStatus. Optionally a single generation can be added.

func NewWatcherWithVersion

func NewWatcherWithVersion(ctx context.Context, watchFunc watchF, c rest.Interface, ns string, resource string, name string, initialResourceVersion string, timeout time.Duration) (watch.Interface, error)

NewWatcherWithVersion makes a watch.Interface on the given resource in the client, falling back to polling if the server does not support Watch.

Types

type ConditionsExtractor

type ConditionsExtractor func(obj runtime.Object) (apis.Conditions, error)

Extract conditions from a runtime object

type EventDone

type EventDone func(ev *watch.Event) bool

EventDone is a marker to stop actual waiting on given event state

type FakeWatch

type FakeWatch struct {

	// Record how often stop was called
	StopCalled int
	// contains filtered or unexported fields
}

Helper for testing watch functionality

func NewFakeWatch

func NewFakeWatch(events []watch.Event) *FakeWatch

Create a new fake watch with the given events which will be send when on start

func (*FakeWatch) ResultChan

func (f *FakeWatch) ResultChan() <-chan watch.Event

Channel for getting the events

func (*FakeWatch) Start

func (f *FakeWatch) Start()

Start and fire events

func (*FakeWatch) Stop

func (f *FakeWatch) Stop()

Stop the watch channel

type MessageCallback

type MessageCallback func(durationSinceState time.Duration, message string)

Callback for event messages

func NoopMessageCallback

func NoopMessageCallback() MessageCallback

NoopMessageCallback is callback which does nothing

func SimpleMessageCallback

func SimpleMessageCallback(out io.Writer) MessageCallback

SimpleMessageCallback returns a callback which prints out a simple event message to a given writer

type Options

type Options struct {
	// Window for how long a ReadyCondition == false has to stay
	// for being considered as an error (useful for flaky reconciliation
	ErrorWindow *time.Duration

	// Timeout for how long to wait at maximum
	Timeout *time.Duration
}

type PollInterval

type PollInterval interface {
	PollChan() <-chan time.Time
	Stop()
}

PollInterval determines when you should poll. Useful to mock out, or for replacing with exponential backoff later.

type Wait

type Wait interface {

	// Wait on resource the resource with this name
	// and write event messages for unknown event to the status writer.
	// Returns an error (if any) and the overall time it took to wait
	Wait(ctx context.Context, name string, initialVersion string, options Options, msgCallback MessageCallback) (error, time.Duration)
}

Interface used for waiting of a resource of a given name to reach a definitive state in its "Ready" condition.

func NewWaitForEvent

func NewWaitForEvent(kind string, watchMaker WatchMaker, eventDone EventDone) Wait

NewWaitForEvent creates a Wait object which waits until a specific event (i.e. when the EventDone function returns true)

func NewWaitForReady

func NewWaitForReady(kind string, watchMaker WatchMaker, extractor ConditionsExtractor) Wait

NewWaitForReady waits until the condition is set to Ready == True

type WatchMaker

type WatchMaker func(ctx context.Context, name string, initialVersion string, timeout time.Duration) (watch.Interface, error)

Create watch which is used when waiting for Ready condition

Jump to

Keyboard shortcuts

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