future

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2023 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTimeOut timed out
	ErrTimeOut = errors.New("timed out")
)

Functions

func SimpleFuture

func SimpleFuture[T any](f func() (T, error)) func() (T, error)

SimpleFuture a simple future func

Types

type Future

type Future[T any] struct {
	Success          bool
	Done             bool
	Result           T
	InterfaceChannel <-chan T
	// contains filtered or unexported fields
}

Future type holds Result and state

func FutureFunc

func FutureFunc[T any](implem interface{}, args ...interface{}) *Future[T]

FutureFunc creates a function that returns its response in future

func (*Future[T]) Get

func (f *Future[T]) Get() (T, error)

Get return the result when available. This is a blocking call

func (*Future[T]) GetWithTimeout

func (f *Future[T]) GetWithTimeout(timeout time.Duration) (T, error)

GetWithTimeout return the result until timeout.

Jump to

Keyboard shortcuts

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