-
Notifications
You must be signed in to change notification settings - Fork 1
feat: per-message ack for log topics #463
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8c2b915
feat: add per-message ack for log topics
pratyush618 33ed4ae
feat: expose per-message ack in Python SDK
pratyush618 bda5a20
feat: expose per-message ack in Node SDK
pratyush618 02843e8
feat: expose per-message ack in Java SDK
pratyush618 07526a3
docs: document per-message ack
pratyush618 7d3d587
fix: compact per-message-acked log topics on Redis
pratyush618 c04ee81
fix: resolve rustdoc links for publish readiness
pratyush618 9a84a06
fix: harden per-message lease (log-mode, paged scan)
pratyush618 88d03e8
docs: document per-message lease as at-least-once
pratyush618 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| //! Per-message ack for log topics (`0007_topic_deliveries`). | ||
| //! | ||
| //! S28 log subscriptions consume with a single high-water-mark cursor, so one | ||
| //! poisoned message blocks the whole subscription. This adds an opt-in | ||
| //! per-message mode: instead of the cursor read, a consumer *leases* each | ||
| //! message with a visibility timeout and acks or nacks it individually. It's a | ||
| //! consumption choice (which read methods you call), not a registration flag — | ||
| //! delivery state per `(subscription, message)` lives in `topic_deliveries`, and | ||
| //! an un-acked lease that expires is redelivered. Idempotent: | ||
| //! `.if_not_exists()` on the table and index. | ||
|
|
||
| use sea_query::{Alias, ColumnDef, Index, Table}; | ||
|
|
||
| use crate::storage::migrate::{ddl, Backend, Migration, Stmt}; | ||
|
|
||
| pub struct M0007TopicDeliveries; | ||
|
|
||
| fn col(name: &str) -> ColumnDef { | ||
| ColumnDef::new(Alias::new(name)) | ||
| } | ||
|
|
||
| fn t(name: &str) -> Alias { | ||
| Alias::new(name) | ||
| } | ||
|
|
||
| impl Migration for M0007TopicDeliveries { | ||
| fn version(&self) -> &'static str { | ||
| "0007_topic_deliveries" | ||
| } | ||
|
|
||
| fn up(&self, b: Backend) -> Vec<Stmt> { | ||
| // Per-(subscription, message) delivery state. `lease_expires_at` bounds | ||
| // an in-flight lease (0 = available for redelivery, e.g. after a nack); | ||
| // `acked` ends the delivery. `attempts` counts (re)deliveries. | ||
| let deliveries = Table::create() | ||
| .table(t("topic_deliveries")) | ||
| .if_not_exists() | ||
| .col(col("topic").text().not_null()) | ||
| .col(col("subscription_name").text().not_null()) | ||
| .col(col("message_id").text().not_null()) | ||
| .col(col("acked").boolean().not_null().default(false)) | ||
| .col(col("attempts").integer().not_null().default(0)) | ||
| .col(col("lease_expires_at").big_integer().not_null().default(0)) | ||
| .col(col("delivered_at").big_integer().not_null().default(0)) | ||
| .primary_key( | ||
| Index::create() | ||
| .col(t("topic")) | ||
| .col(t("subscription_name")) | ||
| .col(t("message_id")), | ||
| ) | ||
| .to_owned(); | ||
|
|
||
| // The lease read's anti-join filters by (topic, subscription, availability). | ||
| let by_sub_lease = Index::create() | ||
| .if_not_exists() | ||
| .name("idx_topic_deliveries_sub_lease") | ||
| .table(t("topic_deliveries")) | ||
| .col(t("topic")) | ||
| .col(t("subscription_name")) | ||
| .col(t("lease_expires_at")) | ||
| .to_owned(); | ||
|
|
||
| vec![ddl(b, &deliveries), ddl(b, &by_sub_lease)] | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.