Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrPreemptionDisabled = fmt.Errorf("allocation is not preemptible")
ErrPreemptionDisabled indicates that an alloction is either non-preemptible or not running.
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 ¶
Acknowledged returns whether a preemption signal has been acknowledged. ID must be a globally unique identifier for the preemptible.
func Preempt ¶
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.
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 (*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(timeout time.Duration, 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.