preemptible

package
v0.0.0-...-3511abf Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultTimeout = time.Hour

DefaultTimeout is the delay before the deadline exceeded callback passed to preempt is called.

View Source
var ErrPreemptionDisabled = fmt.Errorf("allocation is not preemptible")

ErrPreemptionDisabled indicates that an alloction is either non-preemptible or not running.

View Source
var ErrPreemptionTimeoutExceeded = fmt.Errorf("allocation did not preempt in %s", DefaultTimeout)

ErrPreemptionTimeoutExceeded indicates that an allocation not halt within the expected deadline.

Functions

func Acknowledge

func Acknowledge(id string)

Acknowledge the receipt of a preemption signal. ID must be a globally unique identifier for the preemptible.

func Acknowledged

func Acknowledged(id string) bool

Acknowledged returns whether a preemption signal has been acknowledged. ID must be a globally unique identifier for the preemptible.

func Preempt

func Preempt(id string, timeoutCallback TimeoutFn)

Preempt preempts all watchers, marks us as preempted and begins the preemption deadline. The preemption deadline callback can fire until Close is called. ID must be a globally unique identifier for the preemptible.

func Register

func Register(id string)

Register a preempitble to default service. ID must be a globally unique identifier for the preemptible.

func Unregister

func Unregister(id string)

Unregister removes a preemptible from the service. ID must be a globally unique identifier for the preemptible.

func Unwatch

func Unwatch(id string, wID uuid.UUID)

Unwatch removes a preemption watcher. ID must be a globally unique identifier for the preemptible.

Types

type Preemptible

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

Preemptible represents the preemption status of an allocation. An allocation is assumed to be preempted exactly one time. The object is "nil safe" - it'll gracefully handle calls on a nil preemption.

func New

func New() *Preemptible

New initializes a Preemption and returns it.

func (*Preemptible) Acknowledge

func (p *Preemptible) Acknowledge()

Acknowledge acknowledges preemption.

func (*Preemptible) Acknowledged

func (p *Preemptible) Acknowledged() bool

Acknowledged returns if preemption has been acknowledged.

func (*Preemptible) Close

func (p *Preemptible) Close()

Close cancels the preemption timeout callbacks if they haven't started and signals all watchers.

func (*Preemptible) Preempt

func (p *Preemptible) Preempt(timeoutCallback TimeoutFn)

Preempt preempts all watchers, marks us as preempted and begins the preemption deadline, after which the timeout callback will be called. The preemption deadline callback can fire until Close is called.

func (*Preemptible) Unwatch

func (p *Preemptible) Unwatch(id uuid.UUID)

Unwatch unregisters a preemption watcher.

func (*Preemptible) Watch

func (p *Preemptible) Watch(id uuid.UUID) Watcher

Watch sets a watcher up to listen for preemption signals and returns it. TODO(DET-9565): Callers maintaining this ID is unnecessary.

type TimeoutFn

type TimeoutFn func(context.Context, error)

TimeoutFn is called when preemption deadlines are exceeded.

type Watcher

type Watcher struct{ C <-chan struct{} }

Watcher contains a channel which can be polled for a preemption signal. TODO(DET-9565): Use of this watcher pattern here is unnecessary.

func Watch

func Watch(id string, wID uuid.UUID) (Watcher, error)

Watch sets a watcher up to listen for preemption signals and returns it. ID must be a globally unique identifier for the preemptible.

Jump to

Keyboard shortcuts

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