controller

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: May 25, 2026 License: Apache-2.0 Imports: 6 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ack

type Ack[I ID] struct {
	// contains filtered or unexported fields
}

Ack acknowledges a reconciliation request

func (*Ack[I]) Do

func (c *Ack[I]) Do(controller *Controller[I])

Do executes the controller directive

type Backoff

type Backoff func(attempt int) time.Duration

Backoff is a function for computing the backoff duration following a failed request

func ConstantBackoff

func ConstantBackoff(delay time.Duration, maxDelay time.Duration) Backoff

ConstantBackoff computes a constant backoff delay

func ExponentialBackoff

func ExponentialBackoff(initialDelay time.Duration, maxDelay time.Duration) Backoff

ExponentialBackoff computes an exponentially increasing backoff delay

type Controller

type Controller[I ID] struct {
	Log dazl.Logger
	// contains filtered or unexported fields
}

Controller manages a set of control loops for reconciling objects. The type parameter is the type of object identifier reconciled by this controller. To reconcile an object, enqueue the object ID by calling the Reconcile method. Once called, the controller will call the configured Reconciler to reconcile the request until complete.

func NewController

func NewController[I ID](reconciler Reconciler[I], opts ...Option) *Controller[I]

NewController creates a new controller

func (*Controller[I]) Reconcile

func (c *Controller[I]) Reconcile(id I) error

Reconcile reconciles the given object ID

func (*Controller[I]) Stop

func (c *Controller[I]) Stop()

Stop stops the controller

type Directive

type Directive[I ID] interface {
	Do(controller *Controller[I])
}

Directive is a controller directive indicating how to proceed after reconciliation

type Fail

type Fail[I ID] struct {
	Error error
	// contains filtered or unexported fields
}

Fail fails a reconciliation request

func (*Fail[I]) Do

func (f *Fail[I]) Do(controller *Controller[I])

Do executes the controller directive

type ID

type ID interface {
	~string | ~int | ~int32 | ~int64 | ~uint | ~uint32 | ~uint64
	fmt.Stringer
}

ID is an interface to be implemented for object identifiers

type Option

type Option func(*Options)

Option is a Controller option

func WithBufferSize

func WithBufferSize(bufferSize int) Option

WithBufferSize sets the buffer size for reconciliation queues

func WithLog

func WithLog(log dazl.Logger) Option

WithLog sets the Controller Logger

func WithOptions

func WithOptions(options Options) Option

WithOptions sets the Controller options

func WithParallelism

func WithParallelism(parallelism int) Option

WithParallelism sets the number of parallel goroutines to use for reconciliation

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout sets the timeout for each reconciliation cycle

type Options

type Options struct {
	Log         dazl.Logger
	Parallelism int
	BufferSize  int
	Timeout     *time.Duration
}

Options is options for the Controller

type Reconciler

type Reconciler[I ID] func(ctx context.Context, request Request[I]) Directive[I]

Reconciler reconciles an object

type Request

type Request[I ID] struct {
	ID I
	// contains filtered or unexported fields
}

Request is a reconciler request

func (Request[I]) Ack

func (r Request[I]) Ack() *Ack[I]

Ack acknowledges the request was reconciled successfully, removing it from the reconciliation queue.

func (Request[I]) Fail

func (r Request[I]) Fail(err error) *Fail[I]

Fail fails reconciliation of the request, logging the given error and removing it from the reconciliation queue.

func (Request[I]) Requeue

func (r Request[I]) Requeue() *Requeue[I]

Requeue acknowledges successful reconciliation of the request, requeueing the request for further reconciliation.

func (Request[I]) Retry

func (r Request[I]) Retry(err error) *Retry[I]

Retry logs a reconciliation error and retries reconciliation of the request.

type Requeue

type Requeue[I ID] struct {
	// contains filtered or unexported fields
}

Requeue requeues a reconciliation request

func (*Requeue[I]) Do

func (r *Requeue[I]) Do(controller *Controller[I])

Do executes the controller directive

type Retry

type Retry[I ID] struct {
	Error error
	// contains filtered or unexported fields
}

Retry retries a reconciliation request

func (*Retry[I]) After

func (r *Retry[I]) After(delay time.Duration) *RetryAfter[I]

After retries the request after the given delay

func (*Retry[I]) At

func (r *Retry[I]) At(t time.Time) *RetryAt[I]

At retries the request at the given time

func (*Retry[I]) Do

func (r *Retry[I]) Do(controller *Controller[I])

Do executes the controller directive

func (*Retry[I]) With

func (r *Retry[I]) With(backoff Backoff) *RetryWith[I]

With retries the request with the given backoff policy

type RetryAfter

type RetryAfter[I ID] struct {
	*Retry[I]
	// contains filtered or unexported fields
}

RetryAfter retries a reconciliation request after a delay

func (*RetryAfter[I]) Do

func (r *RetryAfter[I]) Do(controller *Controller[I])

Do executes the controller directive

type RetryAt

type RetryAt[I ID] struct {
	*Retry[I]
	// contains filtered or unexported fields
}

RetryAt retries a reconciliation request at a specific time

func (*RetryAt[I]) Do

func (r *RetryAt[I]) Do(controller *Controller[I])

Do executes the controller directive

type RetryWith

type RetryWith[I ID] struct {
	*Retry[I]
	// contains filtered or unexported fields
}

RetryWith retries a reconciliation request with a backoff policy

func (*RetryWith[I]) Do

func (r *RetryWith[I]) Do(controller *Controller[I])

Do executes the controller directive

Jump to

Keyboard shortcuts

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