safeacks

package
v1.26.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SafeAcks

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

SafeAcks is a thread safe structure which allows to handle acknowledgment exchanges with N senders and one receiver. The first sender succeeds, then an error is returned for the subsequent ones. This way, subsequent senders are not stuck sending an acknowledgment when nothing expects it anymore. The signaling design is inspired by point 2 in https://go101.org/article/channel-closing.html SafeAcks can be used to acknowledge that an action happened to the task such as task KILLED. At the moment we utilize SafeAcks to acknowledge that all the requested tasks were killed by mesos (task/manager.go).

func NewAcks

func NewAcks() *SafeAcks

func (*SafeAcks) ExpectsAck

func (a *SafeAcks) ExpectsAck(key string) bool

func (*SafeAcks) RegisterAck

func (a *SafeAcks) RegisterAck(key string) error

func (*SafeAcks) TryReceiveAck

func (a *SafeAcks) TryReceiveAck(key string) bool

TryReceiveAck blocks until an acknowledgment is received and then returns true. It will return false if an acknowledgment for a given key is not expected.

func (*SafeAcks) TrySendAck

func (a *SafeAcks) TrySendAck(key string) error

TrySendAck checks if an acknowledgment is expected and if it is, it blocks until it is received. If an acknowledgment is not expected at the moment of the call (or already was received), nil is returned. If more than one goroutine attempts to send an acknowledgment before it is received, all but one goroutines will receive an error.

Jump to

Keyboard shortcuts

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