-
Notifications
You must be signed in to change notification settings - Fork 0
/
extentions.go
48 lines (35 loc) · 907 Bytes
/
extentions.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
37
38
39
40
41
42
43
44
45
46
47
48
package executors
import (
"context"
"log/slog"
)
type NoopErrorHandler struct {
}
func (d NoopErrorHandler) CatchError(runnable Runnable, e error) {
panic(e)
}
type LogErrorHandler struct {
}
func (d LogErrorHandler) CatchError(runnable Runnable, e error) {
slog.Error("catch error", slog.Any("cause", e))
}
type DiscardErrorHandler struct {
}
func (d DiscardErrorHandler) CatchError(runnable Runnable, e error) {
}
type NoopRejectionPolicy struct {
}
func (d NoopRejectionPolicy) RejectExecution(runnable Runnable, e Executor) error {
return ErrRejectedExecution
}
type DiscardRejectionPolicy struct {
}
func (d DiscardRejectionPolicy) RejectExecution(runnable Runnable, e Executor) error {
return nil
}
type CallerRunsRejectionPolicy struct {
}
func (d CallerRunsRejectionPolicy) RejectExecution(runnable Runnable, e Executor) error {
runnable.Run(context.Background())
return nil
}