Skip to content

Add support for retry + dead-letter policies#11

Merged
jeffijoe merged 19 commits into
mainfrom
retry-dlq
Apr 6, 2026
Merged

Add support for retry + dead-letter policies#11
jeffijoe merged 19 commits into
mainfrom
retry-dlq

Conversation

@jeffijoe
Copy link
Copy Markdown
Owner

@jeffijoe jeffijoe commented Apr 2, 2026

This PR is a continuation of #10 (thanks @jimmyhoran !)

jimmyhoran and others added 6 commits February 19, 2026 19:12
- Added `RetryPolicy` struct to control backoff timing for message redelivery after nacks or deadline expirations.
- Implemented `parse_retry_policy` function to parse retry policy from proto representation.
- Integrated retry policy into subscription handling, allowing for configurable backoff behavior.
- Introduced `RetryQueue` to manage messages waiting for their retry backoff delay.
- Updated `SubscriptionActor` to handle retry logic and track delivery attempts.
- Added tests to verify retry policy functionality and behavior under various conditions.
- Updated `push_loop` method to accept a `max_concurrency` parameter, allowing for configurable concurrent HTTP dispatches per push subscription.
- Modified `PushLoop` struct to store the `max_concurrency` value.
- Adjusted the `run` function to utilize the `max_concurrency` setting, implementing a semaphore to manage concurrent tasks effectively.
- Updated related code in `main.rs` and test helpers to reflect the new concurrency feature.
- Introduced `DeadLetterPolicy` struct to manage message forwarding after exceeding maximum delivery attempts.
- Updated `SubscriptionManager` to validate dead letter topics during subscription creation.
- Enhanced `SubscriptionActor` to handle message redirection to dead letter topics based on the configured policy.
- Added parsing functionality for dead letter policies in the API.
- Implemented tests to ensure correct behavior of dead letter policies, including handling nonexistent topics and message forwarding.
jeffijoe added 10 commits April 2, 2026 16:09
The old formula `time + (time % precision)` only produced correct
results by coincidence at exact 50% boundaries (e.g. 50ms → 100ms).
For most inputs it was wrong — e.g. 199ms rounded to 300ms instead
of 200ms. Replaced with `div_ceil` for correct round-up-to-nearest-
100ms behavior.

Also replaced `lazy_static` with `std::sync::LazyLock` for the EPOCH
static.
Eliminate unnecessary allocations in the hot publish/pull paths:

- Take ownership of PublishRequest instead of borrowing, avoiding a
  full clone of message data and attributes per published message
- Share message Vec across subscriptions using Arc<[Arc<TopicMessage>]>
  instead of cloning the Vec for each subscription on fan-out
- Increase actor mpsc channel buffers from 16 to 128 to reduce
  backpressure under concurrent load
- Remove unnecessary ack_ids.clone() in acknowledge handler

Add criterion benchmarks covering data structures, internal
throughput, and concurrent gRPC publish/pull/ack flows.

Measured improvements (gRPC concurrent benchmarks):
- 16 concurrent clients publishing 256B: -7.4%
- 4 concurrent clients publishing 1KB: -6.6%
- 1 client publishing 64KB: -5.9%
- Full publish+pull+ack pipeline with 1KB: -12.8%
Add dead letter policy, retry policy, and OIDC token pass-through
to supported features. Reorganize the limitations section to better
reflect the current state of the project.
@jeffijoe jeffijoe merged commit 09cb410 into main Apr 6, 2026
19 checks passed
@jeffijoe jeffijoe deleted the retry-dlq branch April 8, 2026 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants