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

[Features] Automatically retry requests on network errors #16

Open
ousmanedev opened this issue Jul 23, 2021 · 4 comments · May be fixed by #20
Open

[Features] Automatically retry requests on network errors #16

ousmanedev opened this issue Jul 23, 2021 · 4 comments · May be fixed by #20
Assignees
Labels
enhancement New feature or request

Comments

@ousmanedev
Copy link
Contributor

Enable automatic retries on requests that fail due to a transient problem by configuring the maximum number of retries:

Global configuration

MagicBell.configure do |config|
  config.api_key = 'MAGICBELL_API_KEY'
  config.api_secret = 'MAGICBELL_API_SECRET'
  config.max_network_retries = 2
end

Per-request configuration

  magicbell = MagicBell::Client.new
  magicbell.max_network_retries = 2

Request example

# If the first request doesn't succeed, it will get retried twice

magicbell.create_notification(
  title: 'Rob assigned a task to you',
  recipients: [{
    external_id: 'DATABASE_ID'
  }]
)
@ousmanedev ousmanedev added the enhancement New feature or request label Jul 23, 2021
@ousmanedev ousmanedev self-assigned this Jul 23, 2021
@ousmanedev
Copy link
Contributor Author

@josuemontano, any thought?

@unamashana
Copy link
Member

@ousmanedev Sounds good. I'd include a default - maybe 2 retries?

@ecomba
Copy link

ecomba commented Nov 21, 2021

As I just started to look into the magicbell-ruby I saw that this issue has been open for quite a while. I was wondering if it would make sense to open a PR to add this new feature before I look into other things.

If so, I was wondering what constitutes a transient problem in this scenario. Are we talking about timeouts, 5xx responses from the server, etc?

Is this something that would make sense to start with (before I jump into jucier bits) @unamashana ?

@unamashana
Copy link
Member

@ecomba Yes, this is a good one to start off with. You are right - transient would be 5xx, timeouts, etc.

The idea comes from support for idempotent requests - https://www.magicbell.com/docs/rest-api/idempotent-requests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
3 participants