Skip to content

feat: replace message_ttl with static max retry count #2638

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 11 commits into from
Aug 4, 2022
Merged

feat: replace message_ttl with static max retry count #2638

merged 11 commits into from
Aug 4, 2022

Conversation

jonas-jonas
Copy link
Member

@jonas-jonas jonas-jonas commented Aug 2, 2022

This PR replaces the courier.message_ttl configuration option with a courier.message_retries option to limit how often the sending of a message is retried before it is marked as abandoned.

This is a breaking change, as it removes the message_ttl config key.

Related issue(s)

#402 #1598

Checklist

  • I have read the contributing guidelines.
  • I have referenced an issue containing the design document if my change introduces a new feature.
  • I am following the contributing code guidelines.
  • I have read the security policy.
  • I confirm that this pull request does not address a security vulnerability.
    If this pull request addresses a security. vulnerability,
    I confirm that I got green light (please contact [email protected]) from the maintainers to push the changes.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added or changed the documentation.

Further Comments

@codecov
Copy link

codecov bot commented Aug 2, 2022

Codecov Report

Merging #2638 (35e9d2e) into master (5a8a484) will decrease coverage by 0.04%.
The diff coverage is 55.22%.

@@            Coverage Diff             @@
##           master    #2638      +/-   ##
==========================================
- Coverage   75.28%   75.23%   -0.05%     
==========================================
  Files         295      295              
  Lines       16627    16672      +45     
==========================================
+ Hits        12517    12544      +27     
- Misses       3157     3170      +13     
- Partials      953      958       +5     
Impacted Files Coverage Δ
courier/message.go 100.00% <ø> (ø)
courier/smtp.go 71.09% <12.50%> (-3.91%) ⬇️
courier/courier_dispatcher.go 54.23% <32.14%> (-2.63%) ⬇️
persistence/sql/persister_courier.go 84.52% <75.00%> (-2.25%) ⬇️
courier/test/persistence.go 100.00% <100.00%> (ø)
driver/config/config.go 82.29% <100.00%> (ø)
driver/registry_default.go 87.14% <100.00%> (+0.11%) ⬆️
persistence/sql/persister.go 71.75% <0.00%> (-1.53%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Member

@aeneasr aeneasr left a comment

Choose a reason for hiding this comment

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

Thank you, looking pretty good! Can you please also add documentation to ory/docs for this new feature? And probably remove the message_ttl key if it was documented?

Comment on lines 50 to 53
maxRetries := c.deps.CourierConfig(ctx).CourierMessageRetries()

for k, msg := range messages {
if time.Now().After(msg.CreatedAt.Add(ttl)) {
if msg.SendCount >= maxRetries {
Copy link
Member

Choose a reason for hiding this comment

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

How can we test that emails won't get send that reach the maximum retry count?

Copy link
Member Author

Choose a reason for hiding this comment

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

That is the existing test. Since messages that have the Abandoned state are no longer queued, they won't be sent out. And they receive that state if the condition msg.SendCount > maxRetries is true.

I would like to have a mock SMTP server here, so we can test this case, because currently we are relying on the fact that no SMTP server is running at baz.com which is not ideal. WDYT about that?

@jonas-jonas
Copy link
Member Author

Can you please also add documentation to ory/docs for this new feature? And probably remove the message_ttl key if it was documented?

There was no documentation about this, I'll add some for the new config.

@jonas-jonas
Copy link
Member Author

I created a PR on the docs repo: ory/docs#941

@jonas-jonas
Copy link
Member Author

I moved the message abandonment logic to the appropriate method for this to work in cloud as well, as discussed, and restructured the tests a bit.

Are there tests in cloud that ensure that that's the case?

@aeneasr aeneasr merged commit b341756 into ory:master Aug 4, 2022
@jonas-jonas jonas-jonas deleted the feat/replaceMessageTTLWithRetryCounter branch August 4, 2022 14:18
peturgeorgievv pushed a commit to senteca/kratos-fork that referenced this pull request Jun 30, 2023
This PR replaces the `courier.message_ttl` configuration option with a `courier.message_retries` option to limit how often the sending of a message is retried before it is marked as `abandoned`. 

BREAKING CHANGES: This is a breaking change, as it removes the `courier.message_ttl` config key and replaces it with a counter `courier.message_retries`.

Closes ory#402
Closes ory#1598
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