forked from failsafe-go/failsafe-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
events.go
36 lines (30 loc) · 852 Bytes
/
events.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package failsafe
import (
"time"
"github.com/failsafe-go/failsafe-go/common"
)
// ExecutionEvent indicates an execution was attempted.
type ExecutionEvent[R any] struct {
ExecutionAttempt[R]
}
// ExecutionScheduledEvent indicates an execution was scheduled.
type ExecutionScheduledEvent[R any] struct {
ExecutionAttempt[R]
// The delay before the next execution attempt.
Delay time.Duration
}
// ExecutionDoneEvent indicates an execution is done.
type ExecutionDoneEvent[R any] struct {
ExecutionStats
// The execution result, else the zero value for R
Result R
// The execution error, else nil
Error error
}
func newExecutionDoneEvent[R any](er *common.PolicyResult[R], stats ExecutionStats) ExecutionDoneEvent[R] {
return ExecutionDoneEvent[R]{
Result: er.Result,
Error: er.Error,
ExecutionStats: stats,
}
}