eventual

package module
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2021 License: Apache-2.0 Imports: 2 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DontWait context.Context

DontWait is an expired context for use in Value.Get. Using DontWait will cause a Value.Get call to return immediately. If the value has not been set, a context.Canceled error will be returned.

Functions

This section is empty.

Types

type Value

type Value interface {
	// Set this Value.
	Set(interface{})

	// Reset clears the currently set value, reverting to the same state as if the Eventual had just
	// been created.
	Reset()

	// Get waits for the value to be set. If the context expires first, an error will be returned.
	//
	// This function will return immediately when called with an expired context. In this case, the
	// value will be returned only if it has already been set; otherwise the context error will be
	// returned. For convenience, see DontWait.
	Get(context.Context) (interface{}, error)
}

Value is an eventual value, meaning that callers wishing to access the value block until it is available.

func NewValue

func NewValue() Value

NewValue creates a new value.

func WithDefault

func WithDefault(defaultValue interface{}) Value

WithDefault creates a new value that returns the given defaultValue if a real value isn't available in time.

Jump to

Keyboard shortcuts

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