reactor

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ContextTimeoutMessage is the message for a context timeout
	ContextTimeoutMessage = "context deadline has been exceeded"

	// RequestTimeoutMessage is the message for a request timeout
	RequestTimeoutMessage = "request timeout has expired"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type NoPodEventsYetFn added in v0.6.0

type NoPodEventsYetFn func(podList *corev1.PodList)

NoPodEventsYetFn when the watch has not received the create event within a reasonable time, where a PodList is also provided in the off chance the Pod completed before the Watch was started.

type OnPodEventFn

type OnPodEventFn func(pod *corev1.Pod) error

OnPodEventFn when a pod is modified this method handles the event.

type PodWatcher

type PodWatcher struct {
	// contains filtered or unexported fields
}

PodWatcher a simple function orchestrator based on watching a given pod and reacting upon the state modifications, should work as a helper to build business logic based on the build POD changes.

func NewPodWatcher

func NewPodWatcher(
	ctx context.Context,
	timeout time.Duration,
	clientset kubernetes.Interface,
	ns string,
) (*PodWatcher, error)

NewPodWatcher instantiate PodWatcher event-loop.

func (*PodWatcher) Connect added in v0.10.0

func (p *PodWatcher) Connect(listOpts metav1.ListOptions) error

Connect is the first of two methods called by Start, and it handles the creation of the watch based on the list options provided. Separating out Connect from Start helps deal with the fake k8s clients, which are used by the unit tests, and the capabilities of their Watch implementation.

func (*PodWatcher) Start

func (p *PodWatcher) Start(listOpts metav1.ListOptions) (*corev1.Pod, error)

Start is a convenience method for capturing the use of both Connect and WaitForCompletion

func (*PodWatcher) Stop

func (p *PodWatcher) Stop()

Stop closes the stop channel, and stops the execution loop.

func (*PodWatcher) WaitForCompletion added in v0.10.0

func (p *PodWatcher) WaitForCompletion() (*corev1.Pod, error)

WaitForCompletion is the second of two methods called by Start, and it runs the event loop based on the watch instantiated (by Connect) against informed pod. In case of errors the loop is interrupted. Separating out WaitForCompletion from Start helps deal with the fake k8s clients, which are used by the unit tests, and the capabilities of their Watch implementation.

func (*PodWatcher) WithNoPodEventsYetFn added in v0.6.0

func (p *PodWatcher) WithNoPodEventsYetFn(fn NoPodEventsYetFn) *PodWatcher

WithNoPodEventsYetFn sets the function executed when the watcher decides it has waited long enough for the first event

func (*PodWatcher) WithOnPodAddedFn

func (p *PodWatcher) WithOnPodAddedFn(fn OnPodEventFn) *PodWatcher

WithOnPodAddedFn sets the function executed when a pod is added.

func (*PodWatcher) WithOnPodDeletedFn

func (p *PodWatcher) WithOnPodDeletedFn(fn OnPodEventFn) *PodWatcher

WithOnPodDeletedFn sets the function executed when a pod is modified.

func (*PodWatcher) WithOnPodModifiedFn

func (p *PodWatcher) WithOnPodModifiedFn(fn OnPodEventFn) *PodWatcher

WithOnPodModifiedFn sets the function executed when a pod is modified.

func (*PodWatcher) WithSkipPodFn

func (p *PodWatcher) WithSkipPodFn(fn SkipPodFn) *PodWatcher

WithSkipPodFn sets the skip function instance.

func (*PodWatcher) WithTimeoutPodFn added in v0.6.0

func (p *PodWatcher) WithTimeoutPodFn(fn TimeoutPodFn) *PodWatcher

WithTimeoutPodFn sets the function executed when the context or request timeout fires

type SkipPodFn

type SkipPodFn func(pod *corev1.Pod) bool

SkipPodFn a given pod instance is informed and expects a boolean as return. When true is returned this container state processing is skipped completely.

type TimeoutPodFn added in v0.6.0

type TimeoutPodFn func(msg string)

TimeoutPodFn when either the context or request timeout expires before the Pod finishes

Jump to

Keyboard shortcuts

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