Skip to content

Commit

Permalink
feat: make Sidekiq retry configurable (#1115)
Browse files Browse the repository at this point in the history
  • Loading branch information
ninoseki authored Sep 10, 2024
1 parent 48f0993 commit fceed27
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
7 changes: 4 additions & 3 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ Alternatively you can set values through `.env` file. Values in `.env` file will

## Sidekiq

| Environment Variable | Type | Description | Default |
| -------------------- | ------ | --------------------- | ------- |
| SIDEKIQ_REDIS_URL | String | Redis URL for Sidekiq | |
| Environment Variable | Type | Description | Default |
| -------------------- | ------- | ---------------------------- | ------- |
| SIDEKIQ_REDIS_URL | String | Redis URL for Sidekiq | |
| SIDEKIQ_RETRY | Integer | Retry times for a failed job | `0` |

!!! tip

Expand Down
4 changes: 4 additions & 0 deletions lib/mihari/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class Config < Anyway::Config
zoomeye_api_key: nil,
# sidekiq
sidekiq_redis_url: nil,
sidekiq_retry: 0,
# others
hide_config_values: true,
ignore_error: false,
Expand Down Expand Up @@ -174,6 +175,9 @@ class Config < Anyway::Config
# @!attribute [r] sidekiq_redis_url
# @return [URI, nil]

# @!attribute [r] sidekiq_retry
# @return [Integer]

def database_url=(val)
super(URI(val.to_s))
end
Expand Down
1 change: 1 addition & 0 deletions lib/mihari/sidekiq/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

Sidekiq.configure_server do |config|
config.redis = {url: Mihari.config.sidekiq_redis_url.to_s}
config.default_job_options = {retry: Mihari.config.sidekiq_retry}
end

Sidekiq.configure_client do |config|
Expand Down

0 comments on commit fceed27

Please sign in to comment.