-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchannel_options.go
55 lines (48 loc) · 1.79 KB
/
channel_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
package rabbitmq
// ChannelOptions are used to describe a channel's configuration.
// Logger is a custom logging interface.
type ChannelOptions struct {
Logger Logger
QOSPrefetch int
QOSGlobal bool
ConfirmMode bool
}
// getDefaultChannelOptions describes the options that will be used when a value isn't provided
func getDefaultChannelOptions() ChannelOptions {
return ChannelOptions{
Logger: stdDebugLogger{},
QOSPrefetch: 10,
QOSGlobal: false,
}
}
// WithChannelOptionsQOSPrefetch returns a function that sets the prefetch count, which means that
// many messages will be fetched from the server in advance to help with throughput.
// This doesn't affect the handler, messages are still processed one at a time.
func WithChannelOptionsQOSPrefetch(prefetchCount int) func(*ChannelOptions) {
return func(options *ChannelOptions) {
options.QOSPrefetch = prefetchCount
}
}
// WithChannelOptionsQOSGlobal sets the qos on the channel to global, which means
// these QOS settings apply to ALL existing and future
// channels on the same connection
func WithChannelOptionsQOSGlobal(options *ChannelOptions) {
options.QOSGlobal = true
}
// WithChannelOptionsLogging sets logging to true on the channel options
// and sets the
func WithChannelOptionsLogging(options *ChannelOptions) {
options.Logger = &stdDebugLogger{}
}
// WithChannelOptionsLogger sets logging to a custom interface.
// Use WithChannelOptionsLogging to just log to stdout.
func WithChannelOptionsLogger(log Logger) func(options *ChannelOptions) {
return func(options *ChannelOptions) {
options.Logger = log
}
}
// WithChannelOptionsConfirm enables confirm mode on the connection
// this is required if channel confirmations should be used
func WithChannelOptionsConfirm(options *ChannelOptions) {
options.ConfirmMode = true
}