sidekiq-cron 2.0.0.rc2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d2fa6abcb1076d5e510764b33d0cfdd18d18fd1e585d79c63d300e37a1e0e6db
4
- data.tar.gz: 4a04a46b7444879c6291a52e783ece82fa3488fe042106eef525ac81cd6a2d72
3
+ metadata.gz: f6e739f09f2271ea9904b73771ac03701be57e5eae64e3dd3963e772cda7bdb2
4
+ data.tar.gz: 2ab0776fd2dad66b0db9ba38904a3edfbc540e854187f7a59ca205a748b4fd74
5
5
  SHA512:
6
- metadata.gz: bfd60ceaa0999e67bcc3a123ea767c8ed222a70621f688b0456f189386065570160e53cae1810dcc045b33b03101af5d3f9255b3c8afe6d963255ea9004ead06
7
- data.tar.gz: b08f12f1ce7ca1495013c9eae44b4469371b2d3aeb6e81675c044133391ce411c6f1f4e71206776632a37b58d7594842ea38a0e2cb94ee18f32a70409b20249a
6
+ metadata.gz: 9231cf42e072213083e19c924a09838185faf20d240db195cba87db8f406443ac83172622e4ed89652d09f669e6ce04b7bae3a7836755b28043350c1e2ca056a
7
+ data.tar.gz: 9b63c398a1e129701a20330c5e801f8f36a04651366ed3f38d01061d86033774eb9fe845097af0041f465083d433f4ef783e1be8abf1d083a43f6e3e714c3057
data/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## 2.0.0
6
+
7
+ Sidekiq-Cron v2 is here! In this release we refactored some internals, plus:
8
+
9
+ - Review web UI translations for all available locales (https://github.com/sidekiq-cron/sidekiq-cron/pull/506)
10
+ - Fix detection of ActiveJob in Sidekiq v7.3.3+ (https://github.com/sidekiq-cron/sidekiq-cron/pull/510)
11
+ - Add retry job configuration option to set Sidekiq retry job option (https://github.com/sidekiq-cron/sidekiq-cron/pull/509)
12
+
13
+ Please take a look to the RC1 and RC2 changes too if you are coming from the v1.X series.
14
+
5
15
  ## 2.0.0.rc2
6
16
 
7
17
  - Remove support for Sidekiq < 6.5 (https://github.com/sidekiq-cron/sidekiq-cron/pull/480)
data/README.md CHANGED
@@ -50,6 +50,7 @@ gem "sidekiq-cron"
50
50
  'namespace' => 'YourNamespace', # groups jobs together in a namespace (Default value is 'default'),
51
51
  'source' => 'dynamic', # source of the job, `schedule`/`dynamic` (default: `dynamic`)
52
52
  'queue' => 'name of queue',
53
+ 'retry' => '5', # Sidekiq (not supported by ActiveJob) number of retries, or false to discard on first failure
53
54
  'args' => '[Array or Hash] of arguments which will be passed to perform method',
54
55
  'date_as_argument' => true, # add the time of execution as last argument of the perform method
55
56
  'active_job' => true, # enqueue job through Active Job interface
@@ -68,16 +69,16 @@ All configuration options:
68
69
 
69
70
  ```ruby
70
71
  Sidekiq::Cron.configure do |config|
71
- config.cron_poll_interval = 10
72
- config.cron_schedule_file = 'config/my_schedule.yml'
73
- config.default_namespace = 'statistics'
74
- config.natural_cron_parsing_mode = :single
75
- config.reschedule_grace_period = 100
76
- config.cron_history_size = 50
72
+ config.cron_poll_interval = 10 # Default is 30
73
+ config.cron_schedule_file = 'config/my_schedule.yml' # Default is 'config/schedule.yml'
74
+ config.cron_history_size = 20 # Default is 10
75
+ config.default_namespace = 'statistics' # Default is 'default'
76
+ config.natural_cron_parsing_mode = :strict # Default is :single
77
+ config.reschedule_grace_period = 300 # Default is 60
77
78
  end
78
79
  ```
79
80
 
80
- If you are using Rails, add them inside an initializer (`config/initializers/sidekiq-cron.rb`).
81
+ If you are using Rails, you should add the above block inside an initializer (`config/initializers/sidekiq-cron.rb`).
81
82
 
82
83
  ### Time, cron and Sidekiq-Cron
83
84
 
@@ -61,6 +61,7 @@ module Sidekiq
61
61
  @message = args["message"]
62
62
  message_data = Sidekiq.load_json(@message) || {}
63
63
  @queue = message_data['queue'] || "default"
64
+ @retry = message_data['retry']
64
65
  elsif @klass
65
66
  message_data = {
66
67
  "class" => @klass.to_s,
@@ -72,7 +73,7 @@ module Sidekiq
72
73
  klass_data = get_job_class_options(@klass)
73
74
  message_data = klass_data.merge(message_data)
74
75
 
75
- # Override queue if set in config,
76
+ # Override queue and retry if set in config,
76
77
  # only if message is hash - can be string (dumped JSON).
77
78
  if args['queue']
78
79
  @queue = message_data['queue'] = args['queue']
@@ -80,6 +81,12 @@ module Sidekiq
80
81
  @queue = message_data['queue'] || "default"
81
82
  end
82
83
 
84
+ if args['retry'] != nil
85
+ @retry = message_data['retry'] = args['retry']
86
+ else
87
+ @retry = message_data['retry']
88
+ end
89
+
83
90
  @message = message_data
84
91
  end
85
92
 
@@ -147,7 +154,7 @@ module Sidekiq
147
154
  end
148
155
 
149
156
  def is_active_job?(klass = nil)
150
- @active_job || defined?(ActiveJob::Base) && (klass || Sidekiq::Cron::Support.constantize(@klass.to_s)) < ActiveJob::Base
157
+ @active_job || defined?(::ActiveJob::Base) && (klass || Sidekiq::Cron::Support.constantize(@klass.to_s)) < ::ActiveJob::Base
151
158
  rescue NameError
152
159
  false
153
160
  end
@@ -166,7 +173,7 @@ module Sidekiq
166
173
  end
167
174
 
168
175
  def enqueue_sidekiq_worker(klass_const)
169
- klass_const.set(queue: queue_name_with_prefix).perform_async(*enqueue_args)
176
+ klass_const.set(queue: queue_name_with_prefix, retry: @retry).perform_async(*enqueue_args)
170
177
  end
171
178
 
172
179
  # Sidekiq worker message.
@@ -181,16 +188,16 @@ module Sidekiq
181
188
 
182
189
  if !"#{@active_job_queue_name_delimiter}".empty?
183
190
  queue_name_delimiter = @active_job_queue_name_delimiter
184
- elsif defined?(ActiveJob::Base) && defined?(ActiveJob::Base.queue_name_delimiter) && !ActiveJob::Base.queue_name_delimiter.empty?
185
- queue_name_delimiter = ActiveJob::Base.queue_name_delimiter
191
+ elsif defined?(::ActiveJob::Base) && defined?(::ActiveJob::Base.queue_name_delimiter) && !::ActiveJob::Base.queue_name_delimiter.empty?
192
+ queue_name_delimiter = ::ActiveJob::Base.queue_name_delimiter
186
193
  else
187
194
  queue_name_delimiter = '_'
188
195
  end
189
196
 
190
197
  if !"#{@active_job_queue_name_prefix}".empty?
191
198
  queue_name = "#{@active_job_queue_name_prefix}#{queue_name_delimiter}#{@queue}"
192
- elsif defined?(ActiveJob::Base) && defined?(ActiveJob::Base.queue_name_prefix) && !"#{ActiveJob::Base.queue_name_prefix}".empty?
193
- queue_name = "#{ActiveJob::Base.queue_name_prefix}#{queue_name_delimiter}#{@queue}"
199
+ elsif defined?(::ActiveJob::Base) && defined?(::ActiveJob::Base.queue_name_prefix) && !"#{::ActiveJob::Base.queue_name_prefix}".empty?
200
+ queue_name = "#{::ActiveJob::Base.queue_name_prefix}#{queue_name_delimiter}#{@queue}"
194
201
  else
195
202
  queue_name = @queue
196
203
  end
@@ -422,6 +429,7 @@ module Sidekiq
422
429
  active_job: @active_job ? "1" : "0",
423
430
  queue_name_prefix: @active_job_queue_name_prefix,
424
431
  queue_name_delimiter: @active_job_queue_name_delimiter,
432
+ retry: @retry.nil? || @retry.is_a?(Numeric) ? @retry : @retry.to_s,
425
433
  last_enqueue_time: serialized_last_enqueue_time,
426
434
  symbolize_args: symbolize_args? ? "1" : "0",
427
435
  }
@@ -1,13 +1,22 @@
1
1
  de:
2
- Job: Job
2
+ AreYouSureDeleteCronJob: Sind Sie sicher, dass sie den Cronjob %{job} löschen wollen?
3
+ AreYouSureDeleteCronJobs: Sind Sie sicher, dass Sie ALLE Cron-Jobs löschen möchten?
4
+ AreYouSureEnqueueCronJob: Sind Sie sicher, dass Sie den %{job} Cron-Job einreihen möchten?
5
+ AreYouSureEnqueueCronJobs: Sind Sie sicher, dass Sie ALLE Cron-Jobs einreihen möchten?
3
6
  Cron: Cron
4
7
  CronJobs: Cronjobs
8
+ CronString: Cron
9
+ DeleteAll: Alle löschen
10
+ Description: Beschreibung
11
+ Disable: Deaktivieren
12
+ DisableAll: Alle deaktivieren
13
+ Enable: Aktivieren
14
+ EnableAll: Alle aktivieren
15
+ EnqueueAll: Alle einreihen
5
16
  EnqueueNow: In Warteschlange
6
- 'Cron string': Cron
7
- AreYouSureDeleteCronJob: Sind Sie sicher, dass sie den Cronjob %{job} löschen wollen?
17
+ Job: Job
18
+ LastEnqueued: Eingereiht
8
19
  NoCronJobsWereFound: Keine Cronjobs gefunden
9
- Enable: Aktivieren
10
- Disable: Deaktivieren
11
- 'Last enqueued': Eingereiht
20
+ NoHistoryWereFound: Keine Historie gefunden
12
21
  disabled: deaktiviert
13
22
  enabled: aktiviert
@@ -1,22 +1,22 @@
1
1
  en:
2
- Job: Job
2
+ AreYouSureDeleteCronJob: Are you sure you want to delete the %{job} cron job?
3
+ AreYouSureDeleteCronJobs: Are you sure you want to delete ALL cron jobs?
4
+ AreYouSureEnqueueCronJob: Are you sure you want to enqueue the %{job} cron job?
5
+ AreYouSureEnqueueCronJobs: Are you sure you want to enqueue ALL cron jobs?
3
6
  Cron: Cron
4
7
  CronJobs: Cron Jobs
5
- EnqueueNow: Enqueue Now
6
- EnableAll: Enable All
8
+ CronString: Cron
9
+ DeleteAll: Delete All
10
+ Description: Description
11
+ Disable: Disable
7
12
  DisableAll: Disable All
13
+ Enable: Enable
14
+ EnableAll: Enable All
8
15
  EnqueueAll: Enqueue All
9
- DeleteAll: Delete All
10
- 'Cron string': Cron
11
- AreYouSureEnqueueCronJobs: Are you sure you want to enqueue ALL cron jobs?
12
- AreYouSureEnqueueCronJob: Are you sure you want to enqueue the %{job} cron job?
13
- AreYouSureDeleteCronJobs: Are you sure you want to delete ALL cron jobs?
14
- AreYouSureDeleteCronJob: Are you sure you want to delete the %{job} cron job?
16
+ EnqueueNow: Enqueue Now
17
+ Job: Job
18
+ LastEnqueued: Last enqueued
15
19
  NoCronJobsWereFound: No cron jobs were found
16
- Enable: Enable
17
- Disable: Disable
18
- 'Last enqueued': Last enqueued
20
+ NoHistoryWereFound: No history were found
19
21
  disabled: disabled
20
22
  enabled: enabled
21
- NoHistoryWereFound: No history were found
22
- Description: Description
@@ -1,22 +1,22 @@
1
1
  id:
2
- Job: Job
2
+ AreYouSureDeleteCronJob: Apakah Anda yakin ingin menghapus cron job %{job}?
3
+ AreYouSureDeleteCronJobs: Apakah Anda yakin ingin menghapus SEMUA cron job?
4
+ AreYouSureEnqueueCronJob: Apakah Anda yakin ingin menambahkan cron job %{job} ke antrian?
5
+ AreYouSureEnqueueCronJobs: Apakah Anda yakin ingin menambahkan SEMUA cron job ke antrian?
3
6
  Cron: Cron
4
- CronJobs: Cron Job
5
- EnqueueNow: Tambahkan ke Antrian Sekarang
6
- EnableAll: Aktifkan Semua
7
+ CronJobs: Cron Jobs
8
+ CronString: Cron
9
+ DeleteAll: Hapus Semua
10
+ Description: Deskripsi
11
+ Disable: Nonaktifkan
7
12
  DisableAll: Nonaktifkan Semua
13
+ Enable: Aktifkan
14
+ EnableAll: Aktifkan Semua
8
15
  EnqueueAll: Tambahkan Semua ke Antrian
9
- DeleteAll: Hapus Semua
10
- 'Cron string': Cron string
11
- AreYouSureEnqueueCronJobs: Apakah Anda yakin ingin menambahkan SEMUA cron job ke antrian?
12
- AreYouSureEnqueueCronJob: Apakah Anda yakin ingin menambahkan cron job %{job} ke antrian?
13
- AreYouSureDeleteCronJobs: Apakah Anda yakin ingin menghapus SEMUA cron job?
14
- AreYouSureDeleteCronJob: Apakah Anda yakin ingin menghapus cron job %{job}?
16
+ EnqueueNow: Tambahkan ke Antrian Sekarang
17
+ Job: Job
18
+ LastEnqueued: Terakhir kali ditambahkan ke antrian
15
19
  NoCronJobsWereFound: Tidak ada cron job
16
- Enable: Aktifkan
17
- Disable: Nonaktifkan
18
- 'Last enqueued': Terakhir kali ditambahkan ke antrian
20
+ NoHistoryWereFound: Tidak ada riwayat
19
21
  disabled: dinonaktifkan
20
22
  enabled: diaktifkan
21
- NoHistoryWereFound: Tidak ada riwayat
22
- Description: Deskripsi
@@ -1,23 +1,22 @@
1
1
  it:
2
- Job: Job
2
+ AreYouSureDeleteCronJob: Vuoi cancellare il cron job '%{job}'?
3
+ AreYouSureDeleteCronJobs: Vuoi cancellare TUTTI i cron job?
4
+ AreYouSureEnqueueCronJob: Vuoi accodare il cron job '%{job}'?
5
+ AreYouSureEnqueueCronJobs: Vuoi accodare TUTTI i cron job?
3
6
  Cron: Cron
4
- CronJobs: Cron job
5
- EnqueueNow: Accoda
6
- EnableAll: Attiva tutto
7
+ CronJobs: Cron Jobs
8
+ CronString: Cron
9
+ DeleteAll: Cancella tutto
10
+ Description: Descrizione
11
+ Disable: Disattiva
7
12
  DisableAll: Disattiva tutto
13
+ Enable: Attiva
14
+ EnableAll: Attiva tutto
8
15
  EnqueueAll: Accoda tutto
9
- DeleteAll: Cancella tutto
10
- "Cron string": Cron
11
- AreYouSureEnqueueCronJobs: Vuoi accodare TUTTI i cron job?
12
- AreYouSureEnqueueCronJob: "Vuoi accodare il cron job '%{job}'?"
13
- AreYouSureDeleteCronJobs: Vuoi cancellare TUTTI i cron job?
14
- AreYouSureDeleteCronJob: "Vuoi cancellare il cron job '%{job}'?"
16
+ EnqueueNow: Accoda
17
+ Job: Job
18
+ LastEnqueued: Ultimo accodamento
15
19
  NoCronJobsWereFound: Nessun cron job trovato
16
- Enable: Attiva
17
- Disable: Disattiva
18
- "Last enqueued": Ultimo accodamento
20
+ NoHistoryWereFound: Nessun evento in cronologia
19
21
  disabled: disattivato
20
22
  enabled: attivato
21
- NoHistoryWereFound: Nessun evento in cronologia
22
- Description: Descrizione
23
- Message: Payload
@@ -1,18 +1,22 @@
1
1
  ja:
2
- Job: ジョブ
2
+ AreYouSureDeleteCronJob: 本当に%{job}のcronジョブを削除しますか?
3
+ AreYouSureDeleteCronJobs: 本当にすべてのcronジョブを削除しますか?
4
+ AreYouSureEnqueueCronJob: %{job} の クロン ジョブをキューに入れてもよろしいですか?
5
+ AreYouSureEnqueueCronJobs: すべての クロン ジョブをキューに入れてもよろしいですか?
3
6
  Cron: Cron
4
7
  CronJobs: Cronジョブ
5
- EnqueueNow: すぐにキューに入れる
6
- EnableAll: すべて有効にする
8
+ CronString: Cron
9
+ DeleteAll: すべて削除
10
+ Description: 説明
11
+ Disable: 無効にする
7
12
  DisableAll: すべて無効にする
13
+ Enable: 有効にする
14
+ EnableAll: すべて有効にする
8
15
  EnqueueAll: すべてキューに入れる
9
- DeleteAll: すべて削除
10
- 'Cron string': Cron
11
- AreYouSureDeleteCronJobs: 本当にすべてのcronジョブを削除しますか?
12
- AreYouSureDeleteCronJob: 本当に%{job}のcronジョブを削除しますか?
16
+ EnqueueNow: すぐにキューに入れる
17
+ Job: ジョブ
18
+ LastEnqueued: 最後のキュー
13
19
  NoCronJobsWereFound: Cronジョブが見つかりませんでした
14
- Enable: 有効にする
15
- Disable: 無効にする
16
- 'Last enqueued': 最後のキュー
20
+ NoHistoryWereFound: 履歴が見つかりませんでした
17
21
  disabled: 無効
18
22
  enabled: 有効
@@ -1,22 +1,22 @@
1
1
  pt:
2
- Job: Tarefa
2
+ AreYouSureDeleteCronJob: Tem certeza de que deseja excluir a tarefa %{job}?
3
+ AreYouSureDeleteCronJobs: Tem certeza de que deseja excluir TODOS as tarefas?
4
+ AreYouSureEnqueueCronJob: Tem certeza de que deseja enfileirar a tarefa %{job}?
5
+ AreYouSureEnqueueCronJobs: Tem certeza de que deseja enfileirar TODOS as tarefas?
3
6
  Cron: Cron
4
7
  CronJobs: Tarefas do Cron
5
- EnqueueNow: Enfileirar agora
6
- EnableAll: Habilitar todos
8
+ CronString: Cron
9
+ DeleteAll: Excluir todos
10
+ Description: Descrição
11
+ Disable: Desabilitar
7
12
  DisableAll: Desabilitar todos
13
+ Enable: Habilitar
14
+ EnableAll: Habilitar todos
8
15
  EnqueueAll: Enfileirar todos
9
- DeleteAll: Excluir todos
10
- 'Cron string': Cron
11
- AreYouSureEnqueueCronJobs: Tem certeza de que deseja enfileirar TODOS as tarefas?
12
- AreYouSureEnqueueCronJob: Tem certeza de que deseja enfileirar a tarefa %{job}?
13
- AreYouSureDeleteCronJobs: Tem certeza de que deseja excluir TODOS as tarefas?
14
- AreYouSureDeleteCronJob: Tem certeza de que deseja excluir a tarefa %{job}?
16
+ EnqueueNow: Enfileirar agora
17
+ Job: Tarefa
18
+ LastEnqueued: Último enfileirado
15
19
  NoCronJobsWereFound: Nenhuma tarefa foi encontrada
16
- Enable: Habilitar
17
- Disable: Desabilitar
18
- 'Last enqueued': Último enfileirado
20
+ NoHistoryWereFound: Nenhum histórico foi encontrado
19
21
  disabled: desabilitado
20
22
  enabled: habilitado
21
- NoHistoryWereFound: Nenhum histórico foi encontrado
22
- Description: Descrição
@@ -1,14 +1,22 @@
1
1
  ru:
2
- Job: Задача
2
+ AreYouSureDeleteCronJob: Вы действительно хотите удалить задачу «%{job}»?
3
+ AreYouSureDeleteCronJobs: Вы уверены, что хотите удалить ВСЕ cron-задачи?
4
+ AreYouSureEnqueueCronJob: Вы уверены, что хотите добавить в очередь cron-задачу %{job}?
5
+ AreYouSureEnqueueCronJobs: Вы уверены, что хотите добавить в очередь ВСЕ cron-задачи?
3
6
  Cron: Cron
4
7
  CronJobs: Периодические задачи
5
- Name: Название
6
- 'Cron string': Периодичность (синтаксис Cron)
8
+ CronString: Периодичность (синтаксис Cron)
9
+ DeleteAll: Удалить все
10
+ Description: Описание
11
+ Disable: Отключить
12
+ DisableAll: Отключить все
13
+ Enable: Включить
14
+ EnableAll: Включить все
15
+ EnqueueAll: Добавить все в очередь
7
16
  EnqueueNow: Запустить
8
- AreYouSureDeleteCronJob: Вы действительно хотите удалить задачу «%{job}»?
17
+ Job: Задача
18
+ LastEnqueued: Последний запуск
9
19
  NoCronJobsWereFound: Не найдено периодических задач
10
- Enable: Включить
11
- Disable: Отключить
12
- 'Last enqueued': Последний запуск
20
+ NoHistoryWereFound: История не найдена
13
21
  disabled: отключено
14
22
  enabled: включено
@@ -1,19 +1,22 @@
1
1
  zh-CN:
2
- Job: 任务
2
+ AreYouSureDeleteCronJob: 你确定删除定时任务(%{job})吗?
3
+ AreYouSureDeleteCronJobs: 你确定删除所有的定时任务吗?
4
+ AreYouSureEnqueueCronJob: 您确定要将 %{job} 的 定时任务 任务加入队列吗?
5
+ AreYouSureEnqueueCronJobs: 您确定要将所有 定时任务 任务加入队列吗?
3
6
  Cron: 定时任务
4
7
  CronJobs: 定时任务列表
5
- EnqueueNow: 立刻执行
6
- EnableAll: 启用所有
8
+ CronString: 定时策略
9
+ DeleteAll: 删除所有
10
+ Description: 描述
11
+ Disable: 禁用
7
12
  DisableAll: 禁用所有
13
+ Enable: 启用
14
+ EnableAll: 启用所有
8
15
  EnqueueAll: 执行所有
9
- DeleteAll: 删除所有
10
- 'Cron string': 定时策略
11
- AreYouSureDeleteCronJobs: 你确定删除所有的定时任务吗?
12
- AreYouSureDeleteCronJob: 你确定删除定时任务(%{job})吗?
16
+ EnqueueNow: 立刻执行
17
+ Job: 任务
18
+ LastEnqueued: 放入队列时间
13
19
  NoCronJobsWereFound: 没有定时任务
14
- Enable: 启用
15
- Disable: 禁用
16
- 'Last enqueued': 放入队列时间
20
+ NoHistoryWereFound: 未找到历史记录
17
21
  disabled: 已禁用
18
22
  enabled: 已启用
19
-
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sidekiq
4
4
  module Cron
5
- VERSION = "2.0.0.rc2"
5
+ VERSION = "2.0.0"
6
6
  end
7
7
  end
@@ -8,20 +8,20 @@
8
8
  <div class='col-sm-7 pull-right h2'>
9
9
  <% if @cron_jobs.size > 0 %>
10
10
  <form action="<%= root_path %>cron/namespaces/<%= @current_namespace %>/all/delete" method="post" class="pull-right">
11
- <%= csrf_tag if respond_to?(:csrf_tag) %>
11
+ <%= csrf_tag %>
12
12
  <input class="btn btn-danger" type="submit" name="delete" value="<%= t('DeleteAll') %>" data-confirm="<%= t('AreYouSureDeleteCronJobs') %>" />
13
13
  </form>
14
14
  <form action="<%= root_path %>cron/namespaces/<%= @current_namespace %>/all/disable" method="post" class="pull-right">
15
- <%= csrf_tag if respond_to?(:csrf_tag) %>
16
- <input class="btn btn-warn" type="submit" name="enque" value="<%= t('DisableAll') %>" />
15
+ <%= csrf_tag %>
16
+ <input class="btn btn-warn" type="submit" name="enqueue" value="<%= t('DisableAll') %>" />
17
17
  </form>
18
18
  <form action="<%= root_path %>cron/namespaces/<%= @current_namespace %>/all/enable" method="post" class="pull-right">
19
- <%= csrf_tag if respond_to?(:csrf_tag) %>
20
- <input class="btn btn-warn" type="submit" name="enque" value="<%= t('EnableAll') %>" />
19
+ <%= csrf_tag %>
20
+ <input class="btn btn-warn" type="submit" name="enqueue" value="<%= t('EnableAll') %>" />
21
21
  </form>
22
- <form action="<%= root_path %>cron/namespaces/<%= @current_namespace %>/all/enque" method="post" class="pull-right">
23
- <%= csrf_tag if respond_to?(:csrf_tag) %>
24
- <input class="btn btn-warn" type="submit" name="enque" value="<%= t('EnqueueAll') %>" data-confirm="<%= t('AreYouSureEnqueueCronJobs') %>" />
22
+ <form action="<%= root_path %>cron/namespaces/<%= @current_namespace %>/all/enqueue" method="post" class="pull-right">
23
+ <%= csrf_tag %>
24
+ <input class="btn btn-warn" type="submit" name="enqueue" value="<%= t('EnqueueAll') %>" data-confirm="<%= t('AreYouSureEnqueueCronJobs') %>" />
25
25
  </form>
26
26
  <% end %>
27
27
  </div>
@@ -31,7 +31,7 @@
31
31
  <div class='row'>
32
32
  <div class="col-sm-12 summary_bar">
33
33
  <ul class="list-unstyled summary row">
34
- <% @namespaces.sort_by { |namespace| namespace[:name] }.each do |namespace| %>
34
+ <% Sidekiq::Cron::Namespace.all_with_count.sort_by { |namespace| namespace[:name] }.each do |namespace| %>
35
35
  <li class="col-sm-1">
36
36
  <a href="<%= root_path %>cron/namespaces/<%= namespace[:name] %>">
37
37
  <span class="count"><%= namespace[:count] %></span>
@@ -50,8 +50,8 @@
50
50
  <tr>
51
51
  <th><%= t('Status') %></th>
52
52
  <th width="50%"><%= t('Name') %></th>
53
- <th><%= t('Cron string') %></th>
54
- <th><%= t('Last enqueued') %></th>
53
+ <th><%= t('CronString') %></th>
54
+ <th><%= t('LastEnqueued') %></th>
55
55
  <th width="180"><%= t('Actions') %></th>
56
56
  </tr>
57
57
  </thead>
@@ -80,25 +80,25 @@
80
80
  <td class="<%= klass %>"><%= job.last_enqueue_time ? relative_time(job.last_enqueue_time) : "-" %></td>
81
81
  <td class="<%= klass %>">
82
82
  <% if job.status == 'enabled' %>
83
- <form action="<%= root_path %>cron/namespaces/<%= job.namespace %>/jobs/<%= escaped_job_name %>/enque" method="post">
84
- <%= csrf_tag if respond_to?(:csrf_tag) %>
85
- <input class='btn btn-warn btn-xs pull-left' type="submit" name="enque" value="<%= t('EnqueueNow') %>" data-confirm="<%= t('AreYouSureEnqueueCronJob', :job => job.name) %>"/>
83
+ <form action="<%= root_path %>cron/namespaces/<%= job.namespace %>/jobs/<%= escaped_job_name %>/enqueue" method="post">
84
+ <%= csrf_tag %>
85
+ <input class='btn btn-warn btn-xs pull-left' type="submit" name="enqueue" value="<%= t('EnqueueNow') %>" data-confirm="<%= t('AreYouSureEnqueueCronJob', :job => job.name) %>"/>
86
86
  </form>
87
87
  <form action="<%= root_path %>cron/namespaces/<%= job.namespace %>/jobs/<%= escaped_job_name %>/disable" method="post">
88
- <%= csrf_tag if respond_to?(:csrf_tag) %>
88
+ <%= csrf_tag %>
89
89
  <input class='btn btn-warn btn-xs pull-left' type="submit" name="disable" value="<%= t('Disable') %>"/>
90
90
  </form>
91
91
  <% else %>
92
- <form action="<%= root_path %>cron/namespaces/<%= job.namespace %>/jobs/<%= escaped_job_name %>/enque" method="post">
93
- <%= csrf_tag if respond_to?(:csrf_tag) %>
94
- <input class='btn btn-warn btn-xs pull-left' type="submit" name="enque" value="<%= t('EnqueueNow') %>" data-confirm="<%= t('AreYouSureEnqueueCronJob', :job => job.name) %>"/>
92
+ <form action="<%= root_path %>cron/namespaces/<%= job.namespace %>/jobs/<%= escaped_job_name %>/enqueue" method="post">
93
+ <%= csrf_tag %>
94
+ <input class='btn btn-warn btn-xs pull-left' type="submit" name="enqueue" value="<%= t('EnqueueNow') %>" data-confirm="<%= t('AreYouSureEnqueueCronJob', :job => job.name) %>"/>
95
95
  </form>
96
96
  <form action="<%= root_path %>cron/namespaces/<%= job.namespace %>/jobs/<%= escaped_job_name %>/enable" method="post">
97
- <%= csrf_tag if respond_to?(:csrf_tag) %>
97
+ <%= csrf_tag %>
98
98
  <input class='btn btn-warn btn-xs pull-left' type="submit" name="enable" value="<%= t('Enable') %>"/>
99
99
  </form>
100
100
  <form action="<%= root_path %>cron/namespaces/<%= job.namespace %>/jobs/<%= escaped_job_name %>/delete" method="post">
101
- <%= csrf_tag if respond_to?(:csrf_tag) %>
101
+ <%= csrf_tag %>
102
102
  <input class='btn btn-xs btn-danger pull-left help-block' type="submit" name="delete" value="<%= t('Delete') %>" data-confirm="<%= t('AreYouSureDeleteCronJob', :job => job.name) %>"/>
103
103
  </form>
104
104
  <% end %>
@@ -7,22 +7,22 @@
7
7
  </div>
8
8
  <div class="span col-sm-7 pull-right h2">
9
9
  <% cron_job_path = "#{root_path}cron/namespaces/#{@current_namespace}/jobs/#{CGI.escape(@job.name).gsub('+', '%20')}" %>
10
- <form action="<%= cron_job_path %>/enque?redirect=<%= cron_job_path %>" class="pull-right" method="post">
11
- <%= csrf_tag if respond_to?(:csrf_tag) %>
12
- <input class="btn btn-warn pull-left" name="enque" type="submit" value="<%= t('EnqueueNow') %>" data-confirm="<%= t('AreYouSureEnqueueCronJob', :job => @job.name) %>" />
10
+ <form action="<%= cron_job_path %>/enqueue?redirect=<%= cron_job_path %>" class="pull-right" method="post">
11
+ <%= csrf_tag %>
12
+ <input class="btn btn-warn pull-left" name="enqueue" type="submit" value="<%= t('EnqueueNow') %>" data-confirm="<%= t('AreYouSureEnqueueCronJob', :job => @job.name) %>" />
13
13
  </form>
14
14
  <% if @job.status == 'enabled' %>
15
15
  <form action="<%= cron_job_path %>/disable?redirect=<%= cron_job_path %>" class="pull-right" method="post">
16
- <%= csrf_tag if respond_to?(:csrf_tag) %>
16
+ <%= csrf_tag %>
17
17
  <input class="btn btn-warn pull-left" name="disable" type="submit" value="<%= t('Disable') %>" />
18
18
  </form>
19
19
  <% else %>
20
20
  <form action="<%= cron_job_path %>/enable?redirect=<%= cron_job_path %>" class="pull-right" method="post">
21
- <%= csrf_tag if respond_to?(:csrf_tag) %>
21
+ <%= csrf_tag %>
22
22
  <input class="btn btn-warn pull-left" name="enable" type="submit" value="<%= t('Enable') %>" />
23
23
  </form>
24
24
  <form action="<%= cron_job_path %>/delete" class="pull-right" method="post">
25
- <%= csrf_tag if respond_to?(:csrf_tag) %>
25
+ <%= csrf_tag %>
26
26
  <input class="btn btn-danger pull-left" data-confirm="<%= t('AreYouSureDeleteCronJob', :job => @job.name) %>" name="delete" type="submit" value="<%= t('Delete') %>" />
27
27
  </form>
28
28
  <% end %>
@@ -9,70 +9,66 @@ module Sidekiq
9
9
  def namespace_redirect_path
10
10
  "#{root_path}cron/namespaces/#{route_params[:namespace]}"
11
11
  end
12
+
13
+ def redirect_to_previous_or_default
14
+ redirect params['redirect'] || namespace_redirect_path
15
+ end
16
+
17
+ def render_erb(view)
18
+ views_path = File.join(File.expand_path("..", __FILE__), "views")
19
+ erb(File.read(File.join(views_path, "#{view}.erb")))
20
+ end
12
21
  end
13
22
 
14
- # Index page of cron jobs.
23
+ # Index page.
15
24
  app.get '/cron' do
16
- view_path = File.join(File.expand_path("..", __FILE__), "views")
17
-
18
25
  @current_namespace = 'default'
26
+ @cron_jobs = Sidekiq::Cron::Job.all(@current_namespace)
19
27
 
20
- @namespaces = Sidekiq::Cron::Namespace.all_with_count
21
-
22
- # Not passing namespace takes all the jobs from the default one.
23
- @cron_jobs = Sidekiq::Cron::Job.all
24
-
25
- render(:erb, File.read(File.join(view_path, "cron.erb")))
28
+ render_erb(:cron)
26
29
  end
27
30
 
31
+ # Detail page for a specific namespace.
28
32
  app.get '/cron/namespaces/:name' do
29
- view_path = File.join(File.expand_path("..", __FILE__), "views")
30
-
31
33
  @current_namespace = route_params[:name]
32
-
33
- @namespaces = Sidekiq::Cron::Namespace.all_with_count
34
-
35
34
  @cron_jobs = Sidekiq::Cron::Job.all(@current_namespace)
36
35
 
37
- render(:erb, File.read(File.join(view_path, "cron.erb")))
36
+ render_erb(:cron)
38
37
  end
39
38
 
40
39
  # Display job detail + jid history.
41
40
  app.get '/cron/namespaces/:namespace/jobs/:name' do
42
- view_path = File.join(File.expand_path("..", __FILE__), "views")
43
-
44
41
  @current_namespace = route_params[:namespace]
45
- @job_name = route_params[:name]
46
-
47
- @namespaces = Sidekiq::Cron::Namespace.all_with_count
48
-
49
- @job = Sidekiq::Cron::Job.find(@job_name, @current_namespace)
42
+ @job = Sidekiq::Cron::Job.find(route_params[:name], @current_namespace)
50
43
 
51
44
  if @job
52
- render(:erb, File.read(File.join(view_path, "cron_show.erb")))
45
+ render_erb(:cron_show)
53
46
  else
54
47
  redirect namespace_redirect_path
55
48
  end
56
49
  end
57
50
 
58
51
  # Enqueue all cron jobs.
59
- app.post '/cron/namespaces/:namespace/all/enque' do
52
+ app.post '/cron/namespaces/:namespace/all/enqueue' do
60
53
  Sidekiq::Cron::Job.all(route_params[:namespace]).each(&:enqueue!)
61
- redirect params['redirect'] || namespace_redirect_path
54
+
55
+ redirect_to_previous_or_default
62
56
  end
63
57
 
64
58
  # Enqueue cron job.
65
- app.post '/cron/namespaces/:namespace/jobs/:name/enque' do
59
+ app.post '/cron/namespaces/:namespace/jobs/:name/enqueue' do
66
60
  if job = Sidekiq::Cron::Job.find(route_params[:name], route_params[:namespace])
67
61
  job.enqueue!
68
62
  end
69
- redirect params['redirect'] || namespace_redirect_path
63
+
64
+ redirect_to_previous_or_default
70
65
  end
71
66
 
72
67
  # Delete all schedules.
73
68
  app.post '/cron/namespaces/:namespace/all/delete' do
74
69
  Sidekiq::Cron::Job.all(route_params[:namespace]).each(&:destroy)
75
- redirect params['redirect'] || namespace_redirect_path
70
+
71
+ redirect_to_previous_or_default
76
72
  end
77
73
 
78
74
  # Delete schedule.
@@ -80,13 +76,15 @@ module Sidekiq
80
76
  if job = Sidekiq::Cron::Job.find(route_params[:name], route_params[:namespace])
81
77
  job.destroy
82
78
  end
83
- redirect params['redirect'] || namespace_redirect_path
79
+
80
+ redirect_to_previous_or_default
84
81
  end
85
82
 
86
83
  # Enable all jobs.
87
84
  app.post '/cron/namespaces/:namespace/all/enable' do
88
85
  Sidekiq::Cron::Job.all(route_params[:namespace]).each(&:enable!)
89
- redirect params['redirect'] || namespace_redirect_path
86
+
87
+ redirect_to_previous_or_default
90
88
  end
91
89
 
92
90
  # Enable job.
@@ -94,13 +92,15 @@ module Sidekiq
94
92
  if job = Sidekiq::Cron::Job.find(route_params[:name], route_params[:namespace])
95
93
  job.enable!
96
94
  end
97
- redirect params['redirect'] || namespace_redirect_path
95
+
96
+ redirect_to_previous_or_default
98
97
  end
99
98
 
100
99
  # Disable all jobs.
101
100
  app.post '/cron/namespaces/:namespace/all/disable' do
102
101
  Sidekiq::Cron::Job.all(route_params[:namespace]).each(&:disable!)
103
- redirect params['redirect'] || namespace_redirect_path
102
+
103
+ redirect_to_previous_or_default
104
104
  end
105
105
 
106
106
  # Disable job.
@@ -108,7 +108,8 @@ module Sidekiq
108
108
  if job = Sidekiq::Cron::Job.find(route_params[:name], route_params[:namespace])
109
109
  job.disable!
110
110
  end
111
- redirect params['redirect'] || namespace_redirect_path
111
+
112
+ redirect_to_previous_or_default
112
113
  end
113
114
  end
114
115
  end
data/lib/sidekiq/cron.rb CHANGED
@@ -14,6 +14,17 @@ module Sidekiq
14
14
  end
15
15
 
16
16
  class Configuration
17
+ # The interval, in seconds, at which to poll for scheduled cron jobs.
18
+ # This determines how frequently the scheduler checks for jobs to enqueue.
19
+ attr_accessor :cron_poll_interval
20
+
21
+ # The path to a YAML file containing multiple cron job schedules.
22
+ attr_accessor :cron_schedule_file
23
+
24
+ # The maximum number of recent cron job execution histories to retain.
25
+ # This value controls how many past job executions are stored.
26
+ attr_accessor :cron_history_size
27
+
17
28
  # The default namespace is used when no namespace is specified.
18
29
  attr_accessor :default_namespace
19
30
 
@@ -26,29 +37,18 @@ module Sidekiq
26
37
  # The poller will not enqueue jobs that are late by more than this amount of seconds.
27
38
  # Defaults to 60 seconds.
28
39
  #
29
- # This is useful when sidekiq (and sidekiq-cron) is not used in zero downtime deployments and
30
- # when the deployment is done and sidekiq-cron starts to catch up, it will consider older
40
+ # This is useful when Sidekiq (and Sidekiq-Cron) is not used in zero downtime deployments and
41
+ # when the deployment is done and Sidekiq-Cron starts to catch up, it will consider older
31
42
  # jobs that missed their schedules during the deployment. E.g., jobs that run once a day.
32
43
  attr_accessor :reschedule_grace_period
33
44
 
34
- # The maximum number of recent cron job execution histories to retain.
35
- # This value controls how many past job executions are stored.
36
- attr_accessor :cron_history_size
37
-
38
- # The interval, in seconds, at which to poll for scheduled cron jobs.
39
- # This determines how frequently the scheduler checks for jobs to enqueue.
40
- attr_accessor :cron_poll_interval
41
-
42
- # The path to a YAML file containing multiple cron job schedules.
43
- attr_accessor :cron_schedule_file
44
-
45
45
  def initialize
46
+ @cron_poll_interval = 30
47
+ @cron_schedule_file = 'config/schedule.yml'
48
+ @cron_history_size = 10
46
49
  @default_namespace = 'default'
47
50
  @natural_cron_parsing_mode = :single
48
51
  @reschedule_grace_period = 60
49
- @cron_history_size = 10
50
- @cron_poll_interval = 30
51
- @cron_schedule_file = 'config/schedule.yml'
52
52
  end
53
53
 
54
54
  def natural_cron_parsing_mode=(mode)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-cron
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.rc2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ondrej Bartas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-19 00:00:00.000000000 Z
11
+ date: 2024-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cronex