Repository navigation
fix(core)!: back off exponentially between retries instead of retrying on every poll (#131) #146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,15 +31,18 @@ class OutboxEntryProcessor( | |
| check(entries.all { it.deliveryType in supportedDeliveryTypes }) { | ||
| "Batch contains an entry with no registered deliverer" | ||
| } | ||
| val outcomes = deliverer.deliverBatch(entries) | ||
| // Read after delivery, like process(): a retry's backoff counts from when the attempt ended, so | ||
| // a slow failure (e.g. a 30 s HTTP timeout) does not eat into it (issue #131). | ||
| val now = clock.instant() | ||
| return deliverer.deliverBatch(entries).map { (entry, result) -> applyResult(entry, result, now) } | ||
| return outcomes.map { (entry, result) -> applyResult(entry, result, now) } | ||
| } | ||
|
|
||
| private fun applyResult(entry: OutboxEntry, result: DeliveryResult, now: java.time.Instant): OutboxEntry = when (result) { | ||
| is DeliveryResult.Success -> entry.toDelivered(now) | ||
| is DeliveryResult.RetriableFailure -> | ||
| if (retryPolicy.shouldRetry(entry.retries)) { | ||
| entry.retry(now, result.error) | ||
| entry.retry(now, result.error, nextAttemptAt = now + retryPolicy.backoff(entry.retries + 1)) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should-fix: the backoff is measured from before delivery, so a slow failure uses up most or all of it. In
The single-entry Suggestion: in |
||
| } else { | ||
| entry.toFailed(now, result.error) | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit (API docs): Java callers lose the 11-argument constructor.
OutboxEntry's constructor has no@JvmOverloads, so the 11-argument JVM constructor is gone and Java callers ofnew OutboxEntry(...)get a compile error. The CHANGELOG only says Kotlincopy/default-argument callers must recompile. Either add@JvmOverloads constructorhere, asRetryPolicyandOutboxProcessorPropertieshave, or mention Java constructor callers in the CHANGELOG.