Skip to content
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

Delayed message support for memory, rabbitmq, redis #19

Merged
merged 1 commit into from
Nov 6, 2023

Conversation

svix-onelson
Copy link
Contributor

@svix-onelson svix-onelson commented Oct 31, 2023

SQS already had support for delays.

This diff adds support for all the remaining backends except for GCP which does not provide a direct way to emulate the delay behavior.

The redis impl is by far the most complicated of the bunch. This version was based heavily on what was built for the OSS svix-server, with adjustments needed to account for "raw payloads" which omniqueue uses for persistence rather than encoding things as JSON.

A single e2e test for each backend was added to demonstrate the delay behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a hatchet job based on what you'll see in https://github.com/svix/svix-webhooks/blob/main/server/svix-server/src/queue/redis.rs

Could be useful to review the original while reading this module.

Comment on lines 285 to 288
// FIXME(onelson): original impl depends on chrono so it can convert to UTC. Should probably do this too.
let timestamp: i64 = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this is good as-is. I verified that SystemTime gives UTC time, regardless of the TZ selection for the process.

Put another way, where running env TZ=America/New_York date shows the tz shift away from my system default of America/Los_Angeles, the output from SystemTime is stable.

@svix-onelson svix-onelson force-pushed the onelson/memory-queue-refactor branch 3 times, most recently from eb0bf1e to b759f6e Compare November 1, 2023 19:11
@svix-onelson svix-onelson marked this pull request as ready for review November 1, 2023 19:12
@svix-onelson svix-onelson requested a review from a team November 1, 2023 19:12
SQS already had support for delays.

This diff adds support for all the remaining backends _except for GCP_ which
does not provide a direct way to emulate the delay behavior.

The redis impl is by far the most complicated of the bunch. This version
was based heavily on what was built for the OSS svix-server, with
adjustments needed to account for "raw payloads" which omniqueue uses
for persistence rather than encoding things as JSON.

A single e2e test for each backend was added to demonstrate the delay
behavior.
@svix-james
Copy link

Looks good to me.

@svix-onelson svix-onelson merged commit 960aab8 into main Nov 6, 2023
3 checks passed
@svix-onelson svix-onelson deleted the onelson/memory-queue-refactor branch November 6, 2023 20:48
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.

2 participants