wait

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2019 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultWaitTimeout is the timeout that is used for wait operations
	// if it is not overridden in the ResourceOptions for a given UID.
	DefaultWaitTimeout = 2 * time.Hour

	// DefaultOptions are used for wait operations that do not set Options in a
	// request.
	DefaultOptions = Options{Timeout: DefaultWaitTimeout}
)

Functions

This section is empty.

Types

type CompletionWait

type CompletionWait struct {
	DynamicClient dynamic.Interface
	ErrOut        io.Writer
}

func (CompletionWait) ConditionFunc

func (w CompletionWait) ConditionFunc(info *resource.Info, o Options) (runtime.Object, bool, error)

ConditionFunc waits on a job to complete. It will also watch the failed status of the job and stops waiting with an error if the job failed.

type ConditionFunc

type ConditionFunc func(info *resource.Info, o Options) (runtime.Object, bool, error)

ConditionFunc is called for every resource that is waited for. It should check if the waiting condition is met or not, and if errors occured while waiting.

func NewCompletionConditionFunc

func NewCompletionConditionFunc(client dynamic.Interface, errOut io.Writer) ConditionFunc

func NewDeletedConditionFunc

func NewDeletedConditionFunc(client dynamic.Interface, errOut io.Writer, uidMap UIDMap) ConditionFunc

type DeletionWait

type DeletionWait struct {
	DynamicClient dynamic.Interface
	ErrOut        io.Writer

	// UID is a map of resource locations to UIDs which can help in identifying
	// objects while waiting.
	UIDMap UIDMap
}

func (DeletionWait) ConditionFunc

func (w DeletionWait) ConditionFunc(info *resource.Info, o Options) (runtime.Object, bool, error)

ConditionFunc waits for something to be deleted.

type FakeWaiter

type FakeWaiter struct {
	sync.Mutex
	Requests []*Request
}

func NewFakeWaiter

func NewFakeWaiter() *FakeWaiter

func (*FakeWaiter) Wait

func (d *FakeWaiter) Wait(r *Request) error

type Options

type Options struct {
	// Timeout is the timeout after which to stop waiting and return an error
	// if the waiting condition was not met yet.
	Timeout time.Duration

	// AllowFailure indicates if an error during waiting for this resource is
	// acceptable. In this case the error will just be logged.
	AllowFailure bool
}

Options are wait options for a single resource.

type Request

type Request struct {
	// Options are options for waiting on resource conditions to meet. If nil,
	// DefaultOptions will be used.
	Options *Options

	// ResourceOptions is a map with Resource UIDs as keys. This allows
	// fine-grained configuration of per-resource wait options. This is
	// optional.
	ResourceOptions ResourceOptions

	// ConditionFn is used to determine when waiting should be stopped.
	ConditionFn ConditionFunc

	// Visitor will be used to walk the resources that should be waited on.
	Visitor resource.Visitor
}

Request is a request to wait for multiple resources.

func (*Request) OptionsFor

func (r *Request) OptionsFor(info *resource.Info) Options

OptionsFor returns Options for a resource info. If the resource has a UID and the request has custom options for it, those will be returned. The default request options will be returned otherwise.

type ResourceLocation

type ResourceLocation struct {
	GroupResource schema.GroupResource
	Namespace     string
	Name          string
}

ResourceLocation holds the location of a resource.

type ResourceOptions

type ResourceOptions map[types.UID]Options

ResourceOptions defines custom wait options for resource UIDs.

type StatusFailedError

type StatusFailedError struct {
	Name             string
	GroupVersionKind schema.GroupVersionKind
}

StatusFailedError is used when a job transitioned into status failed. This is usually an error that might be acceptable and can be handled.

func (StatusFailedError) Error

func (e StatusFailedError) Error() string

Error implements error.

type UIDMap

type UIDMap map[ResourceLocation]types.UID

UIDMap maps ResourceLocation with UID.

type WaitSkippedError

type WaitSkippedError struct {
	Name             string
	GroupVersionKind schema.GroupVersionKind
}

func (WaitSkippedError) Error

func (e WaitSkippedError) Error() string

Error implements error.

type WaitTimeoutError

type WaitTimeoutError struct {
	Err      error
	Resource string
	Name     string
}

func (WaitTimeoutError) Error

func (e WaitTimeoutError) Error() string

type Waiter

type Waiter interface {
	// Wait waits for all resources using the provided options. If no condition
	// func is defined in the options the default condition to wait for is
	// resource deletion.
	Wait(r *Request) error
}

Waiter waits for a condition to meet.

func NewSilentWaiter added in v0.0.2

func NewSilentWaiter(streams genericclioptions.IOStreams) Waiter

NewSilentWaiter creates a new Waiter which discards all wait output.

func NewWaiter

NewWaiter creates a new Waiter value.

Jump to

Keyboard shortcuts

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