Skip to content

Commit ad2e530

Browse files
committed
added connect timeout and corrected message removal
1 parent f390fa1 commit ad2e530

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

rtq/rtq.go

+16-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88

99
"encoding/json"
1010

11+
"net"
12+
1113
"github.com/bhoriuchi/go-bunyan/bunyan"
1214
"github.com/coreos/bbolt"
1315
"github.com/satori/go.uuid"
@@ -197,7 +199,18 @@ func (rt *rtQ) transmit(msgB MessageBatch) error {
197199

198200
req, err := http.NewRequest("POST", rt.cfg.Receiver, bytes.NewBuffer(jsonStr))
199201
req.Header.Set("Content-Type", "application/json")
200-
client := &http.Client{}
202+
203+
var netTransport = &http.Transport{
204+
Dial: (&net.Dialer{
205+
Timeout: 10 * time.Second,
206+
}).Dial,
207+
TLSHandshakeTimeout: 10 * time.Second,
208+
}
209+
210+
client := &http.Client{
211+
Timeout: time.Second * 60,
212+
Transport: netTransport,
213+
}
201214
resp, err := client.Do(req)
202215
if err != nil {
203216
return err
@@ -233,9 +246,8 @@ func (rt *rtQ) tx() {
233246
return
234247
}
235248

236-
// transmission was successful so we can remove
237-
// regardless of the queue size
238-
249+
rt.status("Transmission complete. Removing %d records.", mb.Size)
250+
rt.remove <- mb.Size
239251
rt.waitTx()
240252
}
241253

0 commit comments

Comments
 (0)