-
Notifications
You must be signed in to change notification settings - Fork 14
/
option.go
43 lines (33 loc) · 850 Bytes
/
option.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
package settings
import (
"time"
"github.com/avito-tech/go-transaction-manager/trm/v2"
)
// WithCtxKey sets up trm.CtxKey for the trm.Settings.
func WithCtxKey(key trm.CtxKey) Opt {
return func(s *Settings) error {
*s = s.setCtxKey(&key)
return nil
}
}
// WithPropagation sets up a trm.Propagation for the trm.Settings.
func WithPropagation(p trm.Propagation) Opt {
return func(s *Settings) error {
*s = s.setPropagation(&p)
return nil
}
}
// WithCancelable sets up possibility to cancel child goroutines when parent trm.Transaction was canceled.
func WithCancelable(t bool) Opt {
return func(s *Settings) error {
*s = s.setCancelable(&t)
return nil
}
}
// WithTimeout sets up a timeout for the trm.trm.
func WithTimeout(t time.Duration) Opt {
return func(s *Settings) error {
*s = s.setTimeout(&t)
return nil
}
}