File tree Expand file tree Collapse file tree 2 files changed +39
-22
lines changed Expand file tree Collapse file tree 2 files changed +39
-22
lines changed Original file line number Diff line number Diff line change
1
+ package redis
2
+
3
+ import (
4
+ "time"
5
+
6
+ "github.com/cschleiden/go-workflows/backend"
7
+ )
8
+
9
+ type RedisOptions struct {
10
+ backend.Options
11
+
12
+ BlockTimeout time.Duration
13
+
14
+ AutoExpiration time.Duration
15
+ }
16
+
17
+ type RedisBackendOption func (* RedisOptions )
18
+
19
+ func WithBlockTimeout (timeout time.Duration ) RedisBackendOption {
20
+ return func (o * RedisOptions ) {
21
+ o .BlockTimeout = timeout
22
+ }
23
+ }
24
+
25
+ func WithBackendOptions (opts ... backend.BackendOption ) RedisBackendOption {
26
+ return func (o * RedisOptions ) {
27
+ for _ , opt := range opts {
28
+ opt (& o .Options )
29
+ }
30
+ }
31
+ }
32
+
33
+ // WithAutoExpiration sets the duration after which finished runs will expire from the data store.
34
+ // If set to 0 (default), runs will never expire and need to be manually removed.
35
+ func WithAutoExpiration (expireFinishedRunsAfter time.Duration ) RedisBackendOption {
36
+ return func (o * RedisOptions ) {
37
+ o .AutoExpiration = expireFinishedRunsAfter
38
+ }
39
+ }
Original file line number Diff line number Diff line change @@ -16,28 +16,6 @@ import (
16
16
"go.opentelemetry.io/otel/trace"
17
17
)
18
18
19
- type RedisOptions struct {
20
- backend.Options
21
-
22
- BlockTimeout time.Duration
23
- }
24
-
25
- type RedisBackendOption func (* RedisOptions )
26
-
27
- func WithBlockTimeout (timeout time.Duration ) RedisBackendOption {
28
- return func (o * RedisOptions ) {
29
- o .BlockTimeout = timeout
30
- }
31
- }
32
-
33
- func WithBackendOptions (opts ... backend.BackendOption ) RedisBackendOption {
34
- return func (o * RedisOptions ) {
35
- for _ , opt := range opts {
36
- opt (& o .Options )
37
- }
38
- }
39
- }
40
-
41
19
var _ backend.Backend = (* redisBackend )(nil )
42
20
43
21
func NewRedisBackend (client redis.UniversalClient , opts ... RedisBackendOption ) (* redisBackend , error ) {
You can’t perform that action at this time.
0 commit comments