Async Execution

Failsafe-go can execute a func asynchronously via a goroutine. Async executions return an ExecutionResult which can be used to detect when the execution is done and get the result or error, waiting if needed.

Executing a func asynchronously with a policy is simple:

// Run asynchronously with retries
result := failsafe.With(retryPolicy).RunAsync(SendMessage)
err := result.Error()

// Get asynchronously with retries
result := failsafe.With(retryPolicy).GetAsync(Connect)
connection, err := result.Get()

The Error() and Get() methods block until the execution is done. You can also use IsDone() or the Done() channel to detect when the execution is done:

select {
case <-result.Done():
  connection, err := result.Get()
}