-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathoptions.go
57 lines (46 loc) · 1.07 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
package tackle
import "fmt"
const (
DefaultRetryLimit = 10
DefaultRetryDelay = 10
)
type Options struct {
URL string
ConnectionName string
RemoteExchange string
Service string
RoutingKey string
RetryDelay int32
RetryLimit int32
OnDeadFunc func(Delivery)
}
func (o *Options) GetServiceExchangeName() string {
return fmt.Sprintf("%s.%s", o.Service, o.RoutingKey)
}
func (o *Options) GetQueueName() string {
return fmt.Sprintf("%s.%s", o.Service, o.RoutingKey)
}
func (o *Options) GetConnectionName() string {
if o.ConnectionName != "" {
return o.ConnectionName
}
return ConsumerName
}
func (o *Options) GetDeadQueueName() string {
return fmt.Sprintf("%s.dead", o.GetQueueName())
}
func (o *Options) GetRetryDelay() int32 {
if o.RetryDelay > 0 {
return o.RetryDelay
}
return DefaultRetryDelay
}
func (o *Options) GetRetryLimit() int32 {
if o.RetryLimit > 0 {
return o.RetryLimit
}
return DefaultRetryLimit
}
func (o *Options) GetDelayQueueName() string {
return fmt.Sprintf("%s.delay.%d", o.GetQueueName(), o.GetRetryDelay())
}