Skip to content
This repository has been archived by the owner. It is now read-only.

Conversation

ryanwjackson
Copy link
Collaborator

Fix #20

@ryanwjackson ryanwjackson added the enhancement New feature or request label Sep 26, 2019
@ryanwjackson ryanwjackson self-assigned this Sep 26, 2019
Copy link
Collaborator

@mattgmarcus mattgmarcus left a comment

Choose a reason for hiding this comment

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

just had some comments.

did you get a chance to test this too?


def notify_provider
redis = Redis.new
key = 'webhooks/provider_last_notified_at'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be specific to the organization that you're retrying for? Otherwise, how would you know who was the last organization notified?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@mattgmarcus this is sent to the provider (e.g. ModernTreasury). The event ID is also included in that email. It's not organization-specific, because if the webhook endpoint is down, it's likely down for all organizations.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah got it

notify_provider

event.retries ||= 0
event.retries += 1
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you need an event.save!

mattgmarcus
mattgmarcus previously approved these changes Sep 26, 2019
@ryanwjackson
Copy link
Collaborator Author

@mattgmarcus I do need to add tests for this still.

@ryanwjackson
Copy link
Collaborator Author

@mattgmarcus After some research, it doesn't give you too much control over retries: https://github.com/mperham/sidekiq/wiki/Job-Lifecycle#altering-the-lifecycle

It just allows you to set the number of retries but not the backoff. Here is the hard-coded backoff: https://github.com/mperham/sidekiq/wiki/Error-Handling#automatic-job-retry

If we are OK with that, I can do the following:

  • Remove retries column from events
  • Add exception handling and provider email notifications to Forms::Events::Emit, though will probably need a way to store when we last sent an email. The first retry is 30s and then increases exponentially, so they would get a few emails the first 24 hours if not.
  • Remove Forms::Events::Retry

Thoughts?

@mattgmarcus
Copy link
Collaborator

I say we use the default Sidekiq retry stuff. We can customize later if we want but let's just keep it simpler. Your approach looks good.
As for keeping track of the last emails you got - could we just punt on that and track in a separate ticket? I know that could get annoying to have a bunch of emails with scale. But we can fix this later (i.e. not needed to ship)

@ryanwjackson
Copy link
Collaborator Author

ryanwjackson commented Sep 28, 2019 via email

@mattgmarcus
Copy link
Collaborator

mattgmarcus commented Sep 28, 2019 via email

@ryanwjackson
Copy link
Collaborator Author

ryanwjackson commented Sep 28, 2019 via email

@ryanwjackson
Copy link
Collaborator Author

@mattgmarcus Feel free to merge if you approve (and tests pass). I increased test coverage above 90%, though we have some work to do there in general.

@mattgmarcus mattgmarcus merged commit 70cf102 into master Oct 1, 2019
@mattgmarcus mattgmarcus deleted the rj/retry_webhooks branch October 1, 2019 16:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Retry failed webhooks
2 participants