Skip to content

Commit

Permalink
consumer/producer: improve debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
mreiferson committed Apr 8, 2015
1 parent 46e252c commit aebe75c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,8 @@ func (r *Consumer) resume() {
// pick a random connection to test the waters
conns := r.conns()
if len(conns) == 0 {
// backoff again
r.log(LogLevelWarning, "no connection available to resume")
r.log(LogLevelWarning, "backing off for %.04f seconds", 1)
r.backoff(time.Second)
return
}
Expand All @@ -831,7 +832,8 @@ func (r *Consumer) resume() {
// while in backoff only ever let 1 message at a time through
err := r.updateRDY(choice, 1)
if err != nil {
r.log(LogLevelWarning, "(%s) error updating RDY - %s", choice.String(), err)
r.log(LogLevelWarning, "(%s) error resuming RDY 1 - %s", choice.String(), err)
r.log(LogLevelWarning, "backing off for %.04f seconds", 1)
r.backoff(time.Second)
return
}
Expand All @@ -848,7 +850,11 @@ func (r *Consumer) inBackoffTimeout() bool {
}

func (r *Consumer) maybeUpdateRDY(conn *Conn) {
if r.inBackoff() || r.inBackoffTimeout() {
inBackoff := r.inBackoff()
inBackoffTimeout := r.inBackoffTimeout()
if inBackoff || inBackoffTimeout {
r.log(LogLevelDebug, "(%s) skip sending RDY inBackoff:%v || inBackoffTimeout:%v",
conn, inBackoff, inBackoffTimeout)
return
}

Expand Down
2 changes: 1 addition & 1 deletion producer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestProducerConnection(t *testing.T) {

err := w.Publish("write_test", []byte("test"))
if err != nil {
t.Fatalf("should lazily connect")
t.Fatalf("should lazily connect - %s", err)
}

conn := w.conn.(*Conn)
Expand Down

0 comments on commit aebe75c

Please sign in to comment.