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: 2 modules, 5 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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