/
options.go
74 lines (62 loc) · 1.55 KB
/
options.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package sfnactivityworker
import (
"context"
"time"
"github.com/aws/aws-sdk-go/service/sfn/sfniface"
)
type Options interface {
apply(config) config
}
type optionFunc func(cfg config) config
func (fn optionFunc) apply(cfg config) config {
return fn(cfg)
}
// Overrides the default SFN (Created with default session)
func WithSFN(sfn sfniface.SFNAPI) Options {
return optionFunc(func(cfg config) config {
cfg.sfnApi = sfn
return cfg
})
}
// Overrides the default HeartBeatDelay (60 Seconds)
func WithHeartBeatDelay(delay time.Duration) Options {
return optionFunc(func(cfg config) config {
cfg.heartBeatDelay = delay
return cfg
})
}
// Overrides the default WorkersCount (3)
func WithWorkersCount(workers int) Options {
return optionFunc(func(cfg config) config {
cfg.workers = workers
return cfg
})
}
// Overrides the default PollersCount (3)
func WithPollersCount(pollers int) Options {
return optionFunc(func(cfg config) config {
cfg.pollers = pollers
return cfg
})
}
// Overrides the default Logger (std)
func WithLogger(logger Logger) Options {
return optionFunc(func(cfg config) config {
cfg.logger = logger
return cfg
})
}
// Polling and Activity Handler can be bound to context
func WithContext(ctx context.Context) Options {
return optionFunc(func(cfg config) config {
cfg.ctx = ctx
return cfg
})
}
// Overrides the default Microsecond interval between consecutive Polls
func WithPollInterval(pollInterval time.Duration) Options {
return optionFunc(func(cfg config) config {
cfg.pollInterval = pollInterval
return cfg
})
}