evaluation

package
v1.3.2-rc3 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotInflight is returned if an evaluation is not inflight
	ErrNotInflight = errors.New("evaluation is not inflight")

	// ErrReceiptHandleMismatch is the outstanding eval has a different receiptHandle
	ErrReceiptHandleMismatch = errors.New("evaluation receiptHandle does not match")

	// ErrNackTimeoutReached is returned if an expired evaluation is reset
	ErrNackTimeoutReached = errors.New("evaluation visibility timeout reached")
)

Functions

This section is empty.

Types

type BrokerStats

type BrokerStats struct {
	TotalReady      int
	TotalInflight   int
	TotalPending    int
	TotalWaiting    int
	TotalCancelable int
	DelayedEvals    map[string]*models.Evaluation
	ByScheduler     map[string]*SchedulerStats
}

BrokerStats returns all the stats about the broker

func (*BrokerStats) IsEmpty

func (s *BrokerStats) IsEmpty() bool

IsEmpty returns true if the stats are zero

type InMemoryBroker

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

InMemoryBroker The broker is designed to be entirely in-memory.

func NewInMemoryBroker

func NewInMemoryBroker(params InMemoryBrokerParams) (*InMemoryBroker, error)

NewInMemoryBroker creates a new evaluation broker. This is parameterized with:

  • VisibilityTimeout used for messages. If not acknowledged before this time we assume a Nack and attempt to redeliver.
  • MaxReceiveCount which prevents a failing eval from being endlessly delivered.
  • InitialNackDelay which is the delay before making a first-time Nacked evaluation available again
  • SubsequentNackDelay is the compounding delay before making evaluations available again, after the first Nack.

func (*InMemoryBroker) Ack

func (b *InMemoryBroker) Ack(evalID, receiptHandle string) error

func (*InMemoryBroker) Cancelable

func (b *InMemoryBroker) Cancelable(batchSize int) []*models.Evaluation

Cancelable retrieves a batch of previously-pending evaluations that are now stale and ready to mark for canceling. The eval RPC will call this with a batch size set to avoid sending overly large raft messages.

func (*InMemoryBroker) Dequeue

func (b *InMemoryBroker) Dequeue(types []string, timeout time.Duration) (*models.Evaluation, string, error)

func (*InMemoryBroker) Enabled

func (b *InMemoryBroker) Enabled() bool

Enabled is used to check if the broker is enabled.

func (*InMemoryBroker) Enqueue

func (b *InMemoryBroker) Enqueue(evaluation *models.Evaluation) error

func (*InMemoryBroker) EnqueueAll

func (b *InMemoryBroker) EnqueueAll(evals map[*models.Evaluation]string) error

func (*InMemoryBroker) Inflight

func (b *InMemoryBroker) Inflight(evalID string) (string, bool)

func (*InMemoryBroker) InflightExtend

func (b *InMemoryBroker) InflightExtend(evalID, receiptHandle string) error

func (*InMemoryBroker) Nack

func (b *InMemoryBroker) Nack(evalID, receiptHandle string) error

func (*InMemoryBroker) SetEnabled

func (b *InMemoryBroker) SetEnabled(enabled bool)

SetEnabled is used to control if the broker is enabled.

func (*InMemoryBroker) Stats

func (b *InMemoryBroker) Stats() *BrokerStats

Stats is used to query the state of the broker

type InMemoryBrokerParams

type InMemoryBrokerParams struct {
	VisibilityTimeout    time.Duration
	InitialRetryDelay    time.Duration
	SubsequentRetryDelay time.Duration
	MaxReceiveCount      int
}

type PendingEvaluations

type PendingEvaluations []*models.Evaluation

PendingEvaluations is a list of pending Evaluations for a given job. We implement the container/heap interface so that this is a priority queue.

func (PendingEvaluations) Len

func (p PendingEvaluations) Len() int

Len is for the sorting interface

func (PendingEvaluations) Less

func (p PendingEvaluations) Less(i, j int) bool

Less is for the sorting interface. We flip the check so that the "min" in the min-heap is the element with the highest priority or highest modify index

func (*PendingEvaluations) MarkForCancel

func (p *PendingEvaluations) MarkForCancel() []*models.Evaluation

MarkForCancel is used to clear the pending list of all but the one with the highest modify index and highest priority. It returns a slice of cancelable evals so that Eval.Ack RPCs can write batched raft entries to cancel them. This must be called inside the broker's lock.

func (*PendingEvaluations) Pop

func (p *PendingEvaluations) Pop() interface{}

Pop implements the heap interface and is used to remove an evaluation from the slice

func (*PendingEvaluations) Push

func (p *PendingEvaluations) Push(e interface{})

Push implements the heap interface and is used to add a new evaluation to the slice

func (PendingEvaluations) Swap

func (p PendingEvaluations) Swap(i, j int)

Swap is for the sorting interface

type ReadyEvaluations

type ReadyEvaluations []*models.Evaluation

ReadyEvaluations is a list of ready Evaluations across multiple jobs. We implement the container/heap interface so that this is a priority queue.

func (ReadyEvaluations) Len

func (r ReadyEvaluations) Len() int

Len is for the sorting interface

func (ReadyEvaluations) Less

func (r ReadyEvaluations) Less(i, j int) bool

Less is for the sorting interface. We flip the check so that the "min" in the min-heap is the element with the highest priority

func (ReadyEvaluations) Peek

Peek is used to peek at the next element that would be popped

func (*ReadyEvaluations) Pop

func (r *ReadyEvaluations) Pop() interface{}

Pop is used to remove an evaluation from the slice

func (*ReadyEvaluations) Push

func (r *ReadyEvaluations) Push(e interface{})

Push is used to add a new evaluation to the slice

func (ReadyEvaluations) Swap

func (r ReadyEvaluations) Swap(i, j int)

Swap is for the sorting interface

type SchedulerStats

type SchedulerStats struct {
	Ready    int
	Inflight int
}

SchedulerStats returns the stats per scheduler

func (*SchedulerStats) IsEmpty

func (s *SchedulerStats) IsEmpty() bool

IsEmpty returns true if the scheduler stats are zero

type Watcher added in v1.3.1

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

Watcher is the integration between the jobstore and the evaluation broker. It watches for changes in the jobstore and enqueues evaluations in the broker It also handles populating the evaluation broker with non-terminal evaluations during startup

func NewWatcher added in v1.3.1

func NewWatcher(store jobstore.Store, broker orchestrator.EvaluationBroker) *Watcher

NewWatcher creates a new Watcher

func (*Watcher) Backfill added in v1.3.1

func (w *Watcher) Backfill(ctx context.Context) error

Backfill populates the broker with non-terminal evaluations

func (*Watcher) IsWatching added in v1.3.1

func (w *Watcher) IsWatching() bool

IsWatching returns true if the watcher is currently watching

func (*Watcher) Start added in v1.3.1

func (w *Watcher) Start(ctx context.Context)

Start starts the watcher in a goroutine

func (*Watcher) Stop added in v1.3.1

func (w *Watcher) Stop()

Stop stops the watcher

Jump to

Keyboard shortcuts

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