loading...

re: Fail Fast and Fail Often: Handling API Errors at Scale VIEW POST

FULL DISCUSSION
 

Hey Akshay.

I have one suggestion.One sentry you can configure what exceptions you don't want to log just add it to config of sentry.

Raven.configure do |config|
  config.dns = ''
  config.excluded_exceptions += ['Gitplace::ConnectionTimeout']
end

I would try the approach of Peter too. To use another sidekiqjobs to avoid some api calls.

Example...

class GetPullRequestsJob
  def perform(user, client)
    pull_requests = client.get_pull_requests
    GetCommentsJob.perform_async(client, user, pull_requests)
  end
end

class GetCommentsJob
  def perform(client, user, pull_requests)
    time = user.gitplace_last_sync

    pull_requests.each do |pull_request|
      next if pull_request.created_at < time  # this guy could be in a reject. pull_requests.reject {}.each

      comments = client.get_pull_request_comments(pull_request)
      CreateCommentsJob.perform_async(user, pull_request, comments)

      time = pull_request.created_at
    end
  ensure
    user.update!({ gitplace_last_sync: time })
  end
end

class CreateCommentsJob
  def perform(user, pull_request, comments)
    create_action_item(user, pull_request, comments)
  end
end
code of conduct - report abuse