forked from wagslane/go-rabbitmq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
connection_options.go
47 lines (40 loc) · 1.42 KB
/
connection_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
package rabbitmq
import "time"
// ConnectionOptions are used to describe how a new consumer will be created.
type ConnectionOptions struct {
ReconnectInterval time.Duration
Logger Logger
Config Config
}
// getDefaultConnectionOptions describes the options that will be used when a value isn't provided
func getDefaultConnectionOptions() ConnectionOptions {
return ConnectionOptions{
ReconnectInterval: time.Second * 5,
Logger: stdDebugLogger{},
Config: Config{},
}
}
// WithConnectionOptionsReconnectInterval sets the reconnection interval
func WithConnectionOptionsReconnectInterval(interval time.Duration) func(options *ConnectionOptions) {
return func(options *ConnectionOptions) {
options.ReconnectInterval = interval
}
}
// WithConnectionOptionsLogging sets logging to true on the consumer options
// and sets the
func WithConnectionOptionsLogging(options *ConnectionOptions) {
options.Logger = stdDebugLogger{}
}
// WithConnectionOptionsLogger sets logging to true on the consumer options
// and sets the
func WithConnectionOptionsLogger(log Logger) func(options *ConnectionOptions) {
return func(options *ConnectionOptions) {
options.Logger = log
}
}
// WithConnectionOptionsConfig sets the Config used in the connection
func WithConnectionOptionsConfig(cfg Config) func(options *ConnectionOptions) {
return func(options *ConnectionOptions) {
options.Config = cfg
}
}