-
Notifications
You must be signed in to change notification settings - Fork 0
/
builder.go
77 lines (61 loc) · 1.62 KB
/
builder.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
75
76
77
package amqp
import (
"time"
)
func WithConnectRetries(number uint) *Builder {
return new(Builder).WithConnectRetries(number)
}
func WithConnectPause(pause time.Duration) *Builder {
return new(Builder).WithConnectPause(pause)
}
func WithQueue(queue Queue) *Builder {
return new(Builder).WithQueue(queue)
}
func WithExchange(exchange Exchange) *Builder {
return new(Builder).WithExchange(exchange)
}
func WithEvent(event string) *Builder {
return new(Builder).WithEvent(event)
}
func WithQoS(number int) *Builder {
return new(Builder).WithQoS(number)
}
type Builder struct {
ConnectionParams
ListenerParams
PublisherParams
}
func (builder Builder) WithConnectRetries(number uint) *Builder {
builder.Retries = number
return &builder
}
func (builder Builder) WithConnectPause(pause time.Duration) *Builder {
builder.Pause = pause
return &builder
}
func (builder Builder) WithQueue(queue Queue) *Builder {
builder.Queue = queue
return &builder
}
func (builder Builder) WithExchange(exchange Exchange) *Builder {
builder.Exchange = exchange
return &builder
}
func (builder Builder) WithEvent(event string) *Builder {
builder.Event = event
return &builder
}
func (builder Builder) WithQoS(number int) *Builder {
builder.QoS = number
return &builder
}
func (builder Builder) NewListener(driver *Driver) *Listener {
params := builder.ListenerParams
params.ConnectionParams = builder.ConnectionParams
return NewListener(driver, params)
}
func (builder Builder) NewPublisher(driver *Driver) *Publisher {
params := builder.PublisherParams
params.ConnectionParams = builder.ConnectionParams
return NewPublisher(driver, params)
}