Documentation
¶
Index ¶
- Variables
- func GetAll[T any](futures []*Future[T]) ([]T, error)
- func GetParam[T any](futureParams Params, index int) (ret T, err error)
- func GetResult[T any](f *Future[any]) T
- func WaitAll[T any](futures []*Future[T]) error
- func WaitAllContinueOnError[T any](futures []*Future[T]) []error
- func WaitAllSilently[T any](futures []*Future[T])
- func WaitFor(futures ...*Future[any]) error
- func WaitForContinueOnError(futures ...*Future[any]) []error
- type Future
- type Group
- func (g *Group[T]) Get() ([]T, error)
- func (g *Group[T]) GetFutures() []*Future[T]
- func (g *Group[T]) Go(f func() (T, error)) *Future[T]
- func (g *Group[T]) GoWithParams(f func(params Params) (T, error), param Params) *Future[T]
- func (g *Group[T]) Wait() error
- func (g *Group[T]) WaitContinueOnError() []error
- type Params
- func (p Params) GetBoolParam(index int) bool
- func (p Params) GetBytesParam(index int) []byte
- func (p Params) GetFloat32Param(index int) float32
- func (p Params) GetFloat64Param(index int) float64
- func (p Params) GetInt32Param(index int) int32
- func (p Params) GetInt64Param(index int) int64
- func (p Params) GetIntParam(index int) int
- func (p Params) GetStringParam(index int) string
- func (p Params) GetUInt8Param(index int) uint8
- func (p Params) GetUInt32Param(index int) uint32
- func (p Params) GetUInt64Param(index int) uint64
- func (p Params) GetUIntParam(index int) uint
Constants ¶
This section is empty.
Variables ¶
var (
ErrParamTypeConversionFailed = errors.New("param type conversion failed")
)
Functions ¶
func GetAll ¶
GetAll function waits for the completion of specified futures using the WaitAll function. If any error occurs during the waiting process, it returns an error immediately. Otherwise, it extracts the results from completed futures and returns them as a slice.
Parameters:
- futures: List of futures to wait for.
Return:
- A slice containing the results of completed futures.
- If any error occurs during the waiting process, it returns an error.
func GetResult ¶
GetResult function retrieves the result of a completed Future. It assumes that the Future has completed successfully. Note: This function may panic if the type assertion fails.
Parameters:
- f: Future from which to retrieve the result.
Return:
- The result of the completed Future.
func WaitAll ¶
WaitAll function waits for the completion of specified futures. If any error occurs during the process, it stops waiting and returns the first error encountered.
Parameters:
- futures: List of futures to wait for.
Return:
- If at least one error occurs, it returns the first error encountered.
- If there are no errors, it returns nil.
func WaitAllContinueOnError ¶ added in v0.2.0
WaitAllContinueOnError function waits for the completion of specified futures and continues even if an error occurs during the process. It returns a list of errors that occurred.
Parameters:
- futures: List of futures to wait for.
Return:
- A list of errors that occurred during the execution. The list may be empty if there are no errors.
func WaitAllSilently ¶
WaitAllSilently function waits for the completion of specified futures without collecting or returning any error information. It performs a silent wait using a sync.WaitGroup to wait for all futures to complete.
Parameters:
- futures: List of futures to wait for.
func WaitFor ¶
WaitFor function is a convenience wrapper around the WaitAll function. It waits for the completion of specified futures and returns an error if any of the futures encounters an error.
Parameters:
- futures: Variadic parameter representing a list of futures to wait for.
Return:
- If any error occurs during the waiting process, it returns an error.
func WaitForContinueOnError ¶ added in v0.2.0
WaitForContinueOnError function is a convenience wrapper around the WaitAllContinueOnError function. It waits for the completion of specified futures and continues even if an error occurs during the process. It returns a list of errors that occurred during the execution.
Parameters:
- futures: Variadic parameter representing a list of futures to wait for.
Return:
- A list of errors that occurred during the execution. The list may be empty if there are no errors.
Types ¶
type Future ¶
type Future[T any] struct { Result T Err error IsDone bool // contains filtered or unexported fields }
func RunWithParam ¶ added in v0.2.0
type Group ¶ added in v0.3.0
type Group[T any] struct { // contains filtered or unexported fields }
func (*Group[T]) GetFutures ¶ added in v0.3.0
func (*Group[T]) GoWithParams ¶ added in v0.3.0
func (*Group[T]) WaitContinueOnError ¶ added in v0.3.0
type Params ¶ added in v0.2.0
type Params []any