Skip to content

Commit fb14870

Browse files
Onlineheadspeedywizard
authored andcommitted
Add support of TLS connections (#17)
* Add support of TLS connections (amqps://) * Set default heartbeat to 10s
1 parent 04133b0 commit fb14870

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

client.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ type Client struct {
3636
bo Backoffer
3737
attempt int32
3838
l sync.Mutex
39+
config amqp.Config
3940
}
4041

4142
// Declare used to declare queues/exchanges/bindings.
@@ -118,7 +119,12 @@ func (c *Client) Loop() bool {
118119
atomic.AddInt32(&c.attempt, 1)
119120
}
120121

121-
conn, err = amqp.Dial(c.addr)
122+
// set default Heartbeat to 10 seconds like in original amqp.Dial
123+
if c.config.Heartbeat == 0 {
124+
c.config.Heartbeat = 10 * time.Second
125+
}
126+
127+
conn, err = amqp.DialConfig(c.addr, c.config)
122128

123129
if c.reportErr(err) {
124130
return true
@@ -265,3 +271,10 @@ func BlockingChan(blockingChan chan amqp.Blocking) ClientOpt {
265271
c.blocking = blockingChan
266272
}
267273
}
274+
275+
// Config is a functional option, used to setup extended amqp configuration
276+
func Config(config amqp.Config) ClientOpt {
277+
return func(c *Client) {
278+
c.config = config
279+
}
280+
}

0 commit comments

Comments
 (0)