From d51939cbf40caac737759c644926b4da35b4c0e4 Mon Sep 17 00:00:00 2001 From: Manabu Niseki Date: Tue, 10 Sep 2024 16:30:19 +0900 Subject: [PATCH] feat: make Sidekiq retry configurable --- docs/configuration.md | 7 ++++--- lib/mihari/config.rb | 4 ++++ lib/mihari/sidekiq/application.rb | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index 9be20dc1..3d061f52 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -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 diff --git a/lib/mihari/config.rb b/lib/mihari/config.rb index e922532c..d7a0c025 100644 --- a/lib/mihari/config.rb +++ b/lib/mihari/config.rb @@ -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, @@ -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 diff --git a/lib/mihari/sidekiq/application.rb b/lib/mihari/sidekiq/application.rb index 28ad473e..e470f997 100644 --- a/lib/mihari/sidekiq/application.rb +++ b/lib/mihari/sidekiq/application.rb @@ -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|