-
Notifications
You must be signed in to change notification settings - Fork 22
[CHA-1610] Add support channels batch update #188
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
base: master
Are you sure you want to change the base?
Conversation
spec/channel_batch_updater_spec.rb
Outdated
| def loop_times(times) | ||
| loop do | ||
| begin | ||
| yield() | ||
| return | ||
| rescue StandardError, RSpec::Expectations::ExpectationNotMetError | ||
| raise if times.zero? | ||
| end | ||
|
|
||
| sleep(1) | ||
| times -= 1 | ||
| end | ||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might be missing something, but Ruby already has this built in. Would it make sense to use:
10.times do |i|
# do something
endif you need exception handling this will also work
10.times do |i|
# do something
rescue => e
# handle exception
endIt would keep this a bit simpler.
| def wait_for_task(task_id, timeout_seconds: 120) | ||
| sleep(2) # Initial delay | ||
|
|
||
| timeout_seconds.times do |i| | ||
| task = fetch_task_with_retry(task_id, i) | ||
| next if task.nil? | ||
|
|
||
| expect(task['task_id']).to eq(task_id) | ||
|
|
||
| case task['status'] | ||
| when 'waiting', 'pending', 'running' | ||
| sleep(1) | ||
| when 'completed' | ||
| return task | ||
| when 'failed' | ||
| # If result is empty, continue polling (matches Go behavior) | ||
| result = task['result'] | ||
| if result.nil? || (result.is_a?(Hash) && result.empty?) | ||
| sleep(2) | ||
| elsif rate_limit_error?(task) | ||
| sleep(2) | ||
| else | ||
| raise "Task failed with result: #{task['result']}" | ||
| end | ||
| end | ||
| end | ||
|
|
||
| raise "Task did not complete within #{timeout_seconds} seconds" | ||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 [rubocop] <Metrics/CyclomaticComplexity> reported by reviewdog 🐶
Cyclomatic complexity for wait_for_task is too high. [9/7]
| elsif rate_limit_error?(task) | ||
| sleep(2) | ||
| else | ||
| raise "Task failed with result: #{task['result']}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate branch body detected.
Submit a pull request
https://linear.app/stream/issue/CHA-1610/ruby
CLA
Description of the pull request