ack

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlreadyAckedError

type AlreadyAckedError struct {
}

func (*AlreadyAckedError) Error

func (e *AlreadyAckedError) Error() string

type NackError

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

func (*NackError) Error

func (e *NackError) Error() string

func (*NackError) Unwrap

func (e *NackError) Unwrap() error

type SubTree

type SubTree interface {
	// Send an acknowledgement to indicate the completion of a work on this SubTree. Ack should only be called
	// after all NewSubTree(s) are created
	Ack()

	// Send an negative acknowledgement to indicate that there is an error completing a work on this SubTree.
	// Nack error will be wrapping in a NackError and sent to the error function.
	Nack(err error)

	// Create a New SubTree for additional acknowledgements
	NewSubTree() (SubTree, error)

	// Whether or not this node is acked or nacked (not necessarily the whole tree)
	IsAcked() bool
}

A SubTree is a subset of an ack Tree. Normally, users create SubTree when it expects to receive additional acknowledgements signaling the completions of the same work.

type TimeoutError

type TimeoutError struct {
}

func (*TimeoutError) Error

func (e *TimeoutError) Error() string

type Tree

type Tree interface {
	SubTree

	// Block until either the completion function or the error function is called
	Wait()

	// Whether or not the tree is completed
	IsDone() bool
}

func NewAckTree

func NewAckTree(ctx context.Context, fn func(), errFn func(error)) Tree

Construct a new ack Tree. The constructor takes in a context, a completion function, and an error function as its parameters. Once constructed, the ack Tree will start collecting acknowledgements asynchronously. When it receives all acknowledgements, it will call the completion function. If it does not receive all the acknowledgements before the context timeout/cancellation, it will call the error function. Once the completion function or the error function is called, the ack Tree is considered done, and subsequent acknowledgements are ignored.

Jump to

Keyboard shortcuts

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