Skip to content

Commit

Permalink
misc(nango): Increase the number of job retries in case of RequestLim…
Browse files Browse the repository at this point in the history
…itError (#2798)

## Context

When generating a lot of invoices at once, Nango starts failing with
`Request Limit Exceeded ` error

## Description

This PR increases the number of attempts it makes to retry the failed
jobs. We're changing it from 10 to 100 attempts with `wait:
:polynomially_longer`.
  • Loading branch information
ivannovosad authored Nov 8, 2024
1 parent 8da36e9 commit fe3da1a
Show file tree
Hide file tree
Showing 18 changed files with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class CreateJob < ApplicationJob
queue_as 'integrations'

retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 3
retry_on RequestLimitError, wait: :polynomially_longer, attempts: 10
retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100

def perform(credit_note:)
result = Integrations::Aggregator::CreditNotes::CreateService.call(credit_note:)
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/integrations/aggregator/fetch_items_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class FetchItemsJob < ApplicationJob
queue_as 'integrations'

retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 3
retry_on RequestLimitError, wait: :polynomially_longer, attempts: 10
retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100

def perform(integration:)
result = Integrations::Aggregator::ItemsService.call(integration:)
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/integrations/aggregator/invoices/create_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class CreateJob < ApplicationJob
queue_as 'integrations'

retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 3
retry_on RequestLimitError, wait: :polynomially_longer, attempts: 10
retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100

def perform(invoice:)
result = Integrations::Aggregator::Invoices::CreateService.call(invoice:)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class CreateCustomerAssociationJob < ApplicationJob
queue_as 'integrations'

retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 10
retry_on RequestLimitError, wait: :polynomially_longer, attempts: 10
retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100

def perform(invoice:)
result = Integrations::Aggregator::Invoices::Crm::CreateCustomerAssociationService.call(invoice:)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class CreateJob < ApplicationJob

retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 10
retry_on Integrations::Aggregator::BasePayload::Failure, wait: :polynomially_longer, attempts: 10
retry_on RequestLimitError, wait: :polynomially_longer, attempts: 10
retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100

def perform(invoice:)
result = Integrations::Aggregator::Invoices::Crm::CreateService.call(invoice:)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class UpdateJob < ApplicationJob

retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 10
retry_on Integrations::Aggregator::BasePayload::Failure, wait: :polynomially_longer, attempts: 10
retry_on RequestLimitError, wait: :polynomially_longer, attempts: 10
retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100

def perform(invoice:)
result = Integrations::Aggregator::Invoices::Crm::UpdateService.call(invoice:)
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/integrations/aggregator/payments/create_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class CreateJob < ApplicationJob
queue_as 'integrations'

retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 5
retry_on RequestLimitError, wait: :polynomially_longer, attempts: 10
retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100

def perform(payment:)
result = Integrations::Aggregator::Payments::CreateService.call(payment:)
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/integrations/aggregator/perform_sync_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class PerformSyncJob < ApplicationJob
queue_as 'integrations'

retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 3
retry_on RequestLimitError, wait: :polynomially_longer, attempts: 10
retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100

def perform(integration:, sync_items: true)
sync_result = Integrations::Aggregator::SyncService.call(integration:)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class CreateJob < ApplicationJob
queue_as 'integrations'

retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 3
retry_on RequestLimitError, wait: :polynomially_longer, attempts: 10
retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100

def perform(invoice:)
result = Integrations::Aggregator::SalesOrders::CreateService.call(invoice:)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class SendRestletEndpointJob < ApplicationJob
queue_as 'integrations'

retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 3
retry_on RequestLimitError, wait: :polynomially_longer, attempts: 10
retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100

def perform(integration:)
result = Integrations::Aggregator::SendRestletEndpointService.call(integration:)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class CreateCustomerAssociationJob < ApplicationJob
queue_as 'integrations'

retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 10
retry_on RequestLimitError, wait: :polynomially_longer, attempts: 10
retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100

def perform(subscription:)
result = Integrations::Aggregator::Subscriptions::Crm::CreateCustomerAssociationService.call(subscription:)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class CreateJob < ApplicationJob

retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 10
retry_on Integrations::Aggregator::BasePayload::Failure, wait: :polynomially_longer, attempts: 10
retry_on RequestLimitError, wait: :polynomially_longer, attempts: 10
retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100

def perform(subscription:)
result = Integrations::Aggregator::Subscriptions::Crm::CreateService.call(subscription:)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class UpdateJob < ApplicationJob

retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 10
retry_on Integrations::Aggregator::BasePayload::Failure, wait: :polynomially_longer, attempts: 10
retry_on RequestLimitError, wait: :polynomially_longer, attempts: 10
retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100

def perform(subscription:)
result = Integrations::Aggregator::Subscriptions::Crm::UpdateService.call(subscription:)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class DeployPropertiesJob < ApplicationJob
queue_as 'integrations'

retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 3
retry_on Integrations::Aggregator::RequestLimitError, wait: :polynomially_longer, attempts: 10
retry_on Integrations::Aggregator::RequestLimitError, wait: :polynomially_longer, attempts: 100

def perform(integration:)
result = Integrations::Hubspot::Companies::DeployPropertiesService.call(integration:)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class DeployPropertiesJob < ApplicationJob
queue_as 'integrations'

retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 3
retry_on Integrations::Aggregator::RequestLimitError, wait: :polynomially_longer, attempts: 10
retry_on Integrations::Aggregator::RequestLimitError, wait: :polynomially_longer, attempts: 100

def perform(integration:)
result = Integrations::Hubspot::Contacts::DeployPropertiesService.call(integration:)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class DeployObjectJob < ApplicationJob
queue_as 'integrations'

retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 3
retry_on Integrations::Aggregator::RequestLimitError, wait: :polynomially_longer, attempts: 10
retry_on Integrations::Aggregator::RequestLimitError, wait: :polynomially_longer, attempts: 100

def perform(integration:)
result = Integrations::Hubspot::Invoices::DeployObjectService.call(integration:)
Expand Down
1 change: 1 addition & 0 deletions app/jobs/integrations/hubspot/save_portal_id_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class SavePortalIdJob < ApplicationJob
queue_as 'integrations'

retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 3
retry_on Integrations::Aggregator::RequestLimitError, wait: :polynomially_longer, attempts: 100

def perform(integration:)
result = Integrations::Hubspot::SavePortalIdService.call(integration:)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class DeployObjectJob < ApplicationJob
queue_as 'integrations'

retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 3
retry_on Integrations::Aggregator::RequestLimitError, wait: :polynomially_longer, attempts: 10
retry_on Integrations::Aggregator::RequestLimitError, wait: :polynomially_longer, attempts: 100

def perform(integration:)
result = Integrations::Hubspot::Subscriptions::DeployObjectService.call(integration:)
Expand Down

0 comments on commit fe3da1a

Please sign in to comment.