future

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2020 License: MIT Imports: 2 Imported by: 0

README

Future

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(fn fn.Callable) func() error

New is a wrapper around Factory with no options provided returning a new future

Example
// define the response globally to be set in the callable
var rsp *http.Response

future := New(func() (err error) {
	rsp, err = http.Get("http://example.com")
	return err
})
// do some stuff here

if err := future(); err != nil {
	// handle error
}
defer rsp.Body.Close()
// use the response

func NewWithContext

func NewWithContext(ctx context.Context, fn fn.Callable) func() error

NewWithContext creates a future func with provided callable and context

Types

type Callback

type Callback func(err error)

Callback is a future callback (can be used to notify the status of the operation)

type Factory

type Factory func(fn fn.Callable) func() error

Factory is a future factory

func NewFactory

func NewFactory(opts ...Option) Factory

NewFactory creates new future factory with provided options

type Option

type Option func(o *Options)

Option applies a single retry option to the strategy config

func WithContext

func WithContext(ctx context.Context) Option

WithContext defines future context

type Options

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

Options is a future config

Jump to

Keyboard shortcuts

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