futures

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2021 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsCompleted

func AsCompleted(fs ...*F) <-chan *F

Sends each future as it completes on the returned chan, closing it when everything has been sent.

func AsCompletedDelayed

func AsCompletedDelayed(ctx context.Context, initial []*F, delayed []Delayed) <-chan *F

Returns futures as they complete. Delayed futures are not released until their timeout has passed, or all prior delayed futures, and the initial set have completed. One use case is to prefer the value in some futures over others, such as hitting several origin servers where some are better informed than others.

Types

type Delayed

type Delayed struct {
	Delay time.Duration
	Fs    []*F
}

type F

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

func Start

func Start(fn func() (interface{}, error)) *F

func StartNoError

func StartNoError(fn func() interface{}) *F

func (*F) Done

func (f *F) Done() <-chan struct{}

func (*F) Err

func (f *F) Err() error

func (*F) MustResult

func (f *F) MustResult() interface{}

func (*F) Result

func (f *F) Result() (interface{}, error)

TODO: Just return value.

func (*F) ScanResult

func (f *F) ScanResult(res interface{}) error

func (*F) SetName

func (f *F) SetName(s string)

func (*F) String

func (f *F) String() string

Jump to

Keyboard shortcuts

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