Skip to content

Commit

Permalink
added clarifications, improve log
Browse files Browse the repository at this point in the history
  • Loading branch information
Danlock committed Oct 22, 2024
1 parent 5e67a55 commit fde730d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ This package attempts to provide a wrapper of useful features on top of amqp091,

- Minimal API that doesn't get in the way of lower level access. The amqp091.Connection is there if you need it. amqp-091 knowledge is more transferable since danlock/rmq builds on top of those concepts rather than encapsulating things it doesn't need to.

- Network aware message delivery. Infra can fail so danlock/rmq uses context.Context and default timeouts wherever possible.
- Network aware message delivery. Networks fail so danlock/rmq uses context.Context and default timeouts wherever possible, and tries to redeliver across network failures, unlike amqp091-go.

- One dependency (rabbitmq/amqp091-go).

- Prioritize readability. This means no functions with 5 boolean args.

# Examples

Using an AMQP publisher to publish a message with at least once delivery.
Using an AMQP publisher to publish a message with at least once delivery, that retries for up to a minute on failures.

```
ctx, cancel := context.WithTimeout(context.TODO(), time.Minute)
Expand Down
2 changes: 2 additions & 0 deletions hang_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,6 @@ func Example_hanging() {
if chanDur > (hangTime - (hangTime / 10)) {
log.Fatalf("rmqConn.Channel hung for (%s)", chanDur)
}
// A caveat here is that rmqConn has leaked a goroutine that blocks until the connection sorts itself out.
// If amqp091-go ever fixes https://github.com/rabbitmq/amqp091-go/issues/225 then we can improve this situation.
}
2 changes: 1 addition & 1 deletion publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ func (p *Publisher) PublishUntilAcked(ctx context.Context, confirmTimeout time.D
// resending if it's been longer than confirmTimeout or if they've been nacked.
// confirmTimeout defaults to 1 minute. Recommended to call with context.WithTimeout.
func (p *Publisher) PublishBatchUntilAcked(ctx context.Context, confirmTimeout time.Duration, pubs ...Publishing) error {
logPrefix := "rmq.Publisher.PublishBatchUntilConfirmed"
logPrefix := "rmq.Publisher.PublishBatchUntilAcked"

if len(pubs) == 0 {
return nil
Expand Down

0 comments on commit fde730d

Please sign in to comment.