Documentation ¶
Index ¶
- func Execute(ctx context.Context, strategy ExecutionStrategy, members []Member) ([]proto.Message, error)
- func ExecuteAll(ctx context.Context, members []Member) ([]proto.Message, error)
- func ExecuteAny(ctx context.Context, members []Member) ([]proto.Message, error)
- func ExecuteFast(ctx context.Context, members []Member) (proto.Message, int, error)
- func ExecuteMost(ctx context.Context, members []Member) ([]proto.Message, error)
- func ExecuteOne(ctx context.Context, members []Member) (proto.Message, int, error)
- func ExecuteRace(ctx context.Context, members []Member) (proto.Message, int, error)
- func ExecuteUpTo(ctx context.Context, allowedErrors int, members []Member) ([]proto.Message, error)
- type ExecutionStrategy
- type Member
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Execute ¶
func Execute(ctx context.Context, strategy ExecutionStrategy, members []Member) ([]proto.Message, error)
Execute runs all members according to the provided strategy.
func ExecuteAll ¶
ExecuteAll executes all the member functions in parallel, if any return errors then this will return the first reported error. Incomplete executions will have their context cancelled on error, but this function will not return until all execution have completed.
func ExecuteAny ¶
ExecuteAny executes all the member functions in parallel, if all the members error then this will return the first reported error. Incomplete executions will have their context cancelled on error, but this function will not return until all execution have completed.
func ExecuteFast ¶
ExecuteFast executes all the member functions in parallel, the first non-err response from a member is returned. If all members error then the first error response is returned.
func ExecuteMost ¶
ExecuteMost executes all the member functions in parallel, if more than half of the members error then this will return the first reported error. Incomplete executions will have their context cancelled on error, but this function will not return until all execution have completed.
func ExecuteOne ¶
ExecuteOne executes the first member, if it fails, executes the next, etc. Returns the first successful response and the member index that succeeded. If all fail, the first error recorded will be returned.
func ExecuteRace ¶
ExecuteRace executes all the member functions in parallel, the first response from a member is returned.
func ExecuteUpTo ¶
ExecuteUpTo executes all the member functions in parallel, if more than allowedErrors members return errors then this will return the first reported error. Incomplete executions will have their context cancelled on error, but this function will not return until all execution have completed.
Types ¶
type ExecutionStrategy ¶
type ExecutionStrategy int
ExecutionStrategy defines the possible methods for combining a collection of operations into one result.
const ( ExecutionStrategyUnspecified ExecutionStrategy = iota // Implementation will chose a strategy ExecutionStrategyAll // Execute all, return first error if any fail ExecutionStrategyMost // Execute all, return first error if most fail ExecutionStrategyAny // Execute all, return first error if all fail ExecutionStrategyOne // Execute one, if fail, try the next, return first error if all fail ExecutionStrategyFast // Execute all, return first to successfully respond or first error if all fail ExecutionStrategyRace // Execute all, return first to respond even if it errors )