future

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoResult = errors.New("no result in future")

ErrNoResult is returned when there was no result

Functions

func Load

func Load(loaders ...LoaderFunc)

Types

type Future

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

Future - a shortcut for waiting on the result channel for a result or error.

func NewFuture

func NewFuture(parent context.Context, resultCh <-chan *Result) *Future

NewFuture - instantiate a new future. The result provider must close resultCh after providing a single result.

func NewFutureError

func NewFutureError(parent context.Context, err error) *Future

NewFutureError instantiate a new future but have it immediately return as an error

func (*Future) Get

func (f *Future) Get() (interface{}, error)

Get - get the result or error. Blocks until the future is done or the context is cancelled.

func (*Future) IsDone

func (f *Future) IsDone() bool

IsDone - is the future done.

type LoaderFunc

type LoaderFunc func()

type Result

type Result struct {
	Value interface{}
	Err   error
}

Result - the result of an async call - either value or error.

Jump to

Keyboard shortcuts

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