Documentation
¶
Overview ¶
Package await contains await helper functions for use with tasks.
Index ¶
- func All(awaitables ...*task.Task) ([]interface{}, error)
- func AllAsync(awaitables ...*task.Task) *task.Task
- func AllOrError(awaitables ...*task.Task) ([]interface{}, error)
- func AllOrErrorAsync(awaitables ...*task.Task) *task.Task
- func AllOrErrorWithTimeout(timeout time.Duration, awaitables ...*task.Task) ([]interface{}, error)
- func AllOrErrorWithTimeoutAsync(timeout time.Duration, awaitables ...*task.Task) *task.Task
- func Any(awaitables ...*task.Task) (interface{}, error)
- func AnyAsync(awaitables ...*task.Task) *task.Task
- func AnyWithTimeout(timeout time.Duration, awaitables ...*task.Task) (interface{}, error)
- func AnyWithTimeoutAsync(timeout time.Duration, awaitables ...*task.Task) *task.Task
- func FastAllOrError(awaitables ...*task.Task) ([]interface{}, error)
- func FastAllOrErrorAsync(awaitables ...*task.Task) *task.Task
- func FastAny(awaitables ...*task.Task) (interface{}, error)
- func FastAnyAsync(awaitables ...*task.Task) *task.Task
- func MustAll(awaitables ...*task.Task) []interface{}
- func MustAllOrError(awaitables ...*task.Task) []interface{}
- func MustAllOrErrorWithTimeout(timeout time.Duration, awaitables ...*task.Task) []interface{}
- func MustAny(awaitables ...*task.Task) interface{}
- func MustAnyWithTimeout(timeout time.Duration, awaitables ...*task.Task) interface{}
- func MustFastAllOrError(awaitables ...*task.Task) []interface{}
- func MustFastAny(awaitables ...*task.Task) interface{}
- type ErrTaskFailed
- type StreamInstance
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func All ¶
All will wait for every given task to emit a result, the results (& errors) will be returned in a slice ordered the same as the input.
func AllOrError ¶
AllOrError will wait for every given task to emit a result or return as soon as an error is encountered, stopping all other tasks.
func AllOrErrorAsync ¶ added in v2.1.0
AllOrErrorAsync does the same thing as AllOrError but does so asynchronously
func AllOrErrorWithTimeout ¶
AllOrErrorWithTimeout does the same as AllOrError but allows you to set a timeout for waiting for other tasks to stop.
func AllOrErrorWithTimeoutAsync ¶ added in v2.1.0
AllOrErrorWithTimeoutAsync does the same thing as AllOrErrorWithTimeout but does so asynchronously
func Any ¶
Any will wait for the first task to emit a result (or an error) and return that, stopping all other tasks.
func AnyWithTimeout ¶
AnyWithTimeout does the same as Any but allows you to set a timeout for waiting for other tasks to stop.
func AnyWithTimeoutAsync ¶ added in v2.1.0
AnyWithTimeoutAsync does the same thing as AnyWithTimeout but does so asynchronously
func FastAllOrError ¶
FastAllOrError does the same as AllOrError but does not wait for all other tasks to stop, it does tell them to stop it just doesn't wait for them to stop.
func FastAllOrErrorAsync ¶ added in v2.1.0
FastAllOrErrorAsync does the same thing as FastAllOrError but does so asynchronously
func FastAny ¶
FastAny does the same as Any but does not wait for all other tasks to stop, it does tell them to stop it just doesn't wait for them to stop.
func FastAnyAsync ¶ added in v2.1.0
FastAnyAsync does the same thing as FastAny but does so asynchronously
func MustAllOrError ¶
MustAllOrError does the same thing as AllOrError but panics if an error is encountered
func MustAllOrErrorWithTimeout ¶
MustAllOrErrorWithTimeout does the same thing as AllOrErrorWithTimeout but panics if an error is encountered
func MustAnyWithTimeout ¶
MustAnyWithTimeout does the same thing as AnyWithTimeout but panics if an error is encountered
func MustFastAllOrError ¶
MustFastAllOrError does the same thing as FastAllOrError but panics if an error is encountered
func MustFastAny ¶
MustFastAny does the same thing as FastAny but panics if an error is encountered
Types ¶
type ErrTaskFailed ¶
type ErrTaskFailed struct {
Errors []error
}
ErrTaskFailed is returned by the All methods when at least one task returns an error.
func (*ErrTaskFailed) Error ¶
func (e *ErrTaskFailed) Error() string
type StreamInstance ¶ added in v2.1.0
type StreamInstance struct {
// contains filtered or unexported fields
}
StreamInstance is the object that is returned by Stream
func Stream ¶ added in v2.1.0
func Stream(awaitables ...*task.Task) *StreamInstance
Stream will wait for the first task to return and continue to do that until all tasks have returned.
For example:
s := await.Stream(foo(), bar())
for s.Wait() {
r, err := s.Result()
}
func (*StreamInstance) MustResult ¶ added in v2.1.0
func (s *StreamInstance) MustResult() interface{}
MustResult is an alias for the completed task's MustResult method.
func (*StreamInstance) Result ¶ added in v2.1.0
func (s *StreamInstance) Result() (interface{}, error)
Result is an alias for the completed task's Result method.
func (*StreamInstance) Task ¶ added in v2.1.0
func (s *StreamInstance) Task() *task.Task
Task return the completed task
func (*StreamInstance) Wait ¶ added in v2.1.0
func (s *StreamInstance) Wait() bool
Wait will return true once a task has finished & then remove that task from the list of tasks to wait for. It will return false when there are no more tasks to wait for.