Skip to content

Commit

Permalink
Merge pull request #61 from wework/log-cleanup
Browse files Browse the repository at this point in the history
log only when messages were sent:
  • Loading branch information
Guy Baron authored May 5, 2019
2 parents eea9d56 + da82ab3 commit d0bb819
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion gbus/tx/mysql/txoutbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,9 @@ func (outbox *TxOutbox) sendMessages(recordSelector func(tx *sql.Tx) (*sql.Rows,
if err != nil {
outbox.log().WithError(err).Error("could not close Rows")
}
outbox.log().WithField("messages_sent", len(successfulDeliveries)).Info("outbox relayed messages")
if messagesSent := len(successfulDeliveries); messagesSent > 0 {
outbox.log().WithField("messages_sent", len(successfulDeliveries)).Info("outbox relayed messages")
}
for deliveryTag, id := range successfulDeliveries {
_, updateErr := tx.Exec("UPDATE "+getOutboxName(outbox.svcName)+" SET status=1, delivery_tag=?, relay_id=? WHERE rec_id=?", deliveryTag, outbox.ID, id)
if updateErr != nil {
Expand Down
3 changes: 2 additions & 1 deletion gbus/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,15 @@ func (worker *worker) resolveHandlers(isRPCreply bool, bm *BusMessage, delivery
} else {
worker.handlersLock.Lock()
defer worker.handlersLock.Unlock()
worker.log().WithFields(log.Fields{"number_of_handlers": len(worker.registrations)}).Info("found message handlers")

for _, registration := range worker.registrations {
if registration.Matches(delivery.Exchange, delivery.RoutingKey, bm.PayloadFQN) {
handlers = append(handlers, registration.Handler)
}
}
}

worker.log().WithFields(log.Fields{"number_of_handlers": len(handlers)}).Info("found message handlers")
return handlers
}

Expand Down

0 comments on commit d0bb819

Please sign in to comment.