Skip to content

Commit

Permalink
Set the maximum diff on timeouts
Browse files Browse the repository at this point in the history
Signed-off-by: Piotr Piotrowski <[email protected]>
  • Loading branch information
piotrpio committed Aug 2, 2024
1 parent 6970ba4 commit 81bf320
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions js.go
Original file line number Diff line number Diff line change
Expand Up @@ -2899,7 +2899,11 @@ func (sub *Subscription) Fetch(batch int, opts ...PullOpt) ([]*Msg, error) {
}

// Make our request expiration a bit shorter than the current timeout.
expires := time.Duration(float64(ttl) * 0.9)
expiresDiff := time.Duration(float64(ttl) * 0.1)
if expiresDiff > 5*time.Second {
expiresDiff = 5 * time.Second
}
expires := ttl - expiresDiff

nr.Batch = batch - len(msgs)
nr.Expires = expires
Expand Down Expand Up @@ -3163,7 +3167,11 @@ func (sub *Subscription) FetchBatch(batch int, opts ...PullOpt) (MessageBatch, e
ttl = time.Until(deadline)

// Make our request expiration a bit shorter than the current timeout.
expires := time.Duration(float64(ttl) * 0.9)
expiresDiff := time.Duration(float64(ttl) * 0.1)
if expiresDiff > 5*time.Second {
expiresDiff = 5 * time.Second
}
expires := ttl - expiresDiff

requestBatch := batch - len(result.msgs)
req := nextRequest{
Expand Down

0 comments on commit 81bf320

Please sign in to comment.