cloudtasker 0.12.rc4 → 0.12.rc5

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: 21f0b0582c4e3b2f54cae9a7086da5a4c62f238d3f4fdaf54d78bccd7e27eff2
4
- data.tar.gz: 6811ae33e4d082fafa62bb0f8021bb0cf6f36e63aa50d1683f409c3176f8a10f
3
+ metadata.gz: a1f63a9bfefe90d0cfa0d6b567098ec72efe150894fbd878daa72fe934d27a25
4
+ data.tar.gz: 347d6358120bd83f116b569fafcd0313a96d8c34a4f6222ca20b0dedda866098
5
5
  SHA512:
6
- metadata.gz: e155f136b3da0480e0644d883f275a013bd4694517d880c18a68527b16940362ee07caa1d3f8ebd303de6078fee565cf7088b425a389f0be53ee847ead91e678
7
- data.tar.gz: f682af3f433e48739b0a631e593d285fe5854e789e08f93bbd2670eb08474f6d5a3dd12019f428ff596ef3c5a67b384b36d22dcd786d2c20f827669b92454b2b
6
+ metadata.gz: a4ecf9ad17d612133653f70e7691fc746742c3ca62eb8f67c09bdc1992776391e755a5c674b97d0339bd74514958299062610d448b089fe5995dd6abe5756021
7
+ data.tar.gz: 231f0ba89cf89db4bdb138a1d34d10688161d156c9898da7a067783f75f930b9318a08dfdf240188e23dfa3a0e9dd59b38b1b235b5ab5038eb6727a244877017
data/.rubocop.yml CHANGED
@@ -6,7 +6,7 @@ AllCops:
6
6
  - 'vendor/**/*'
7
7
 
8
8
  Metrics/ClassLength:
9
- Max: 150
9
+ Max: 200
10
10
 
11
11
  Metrics/ModuleLength:
12
12
  Max: 150
data/CHANGELOG.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Changelog
2
2
 
3
- ## Latest RC [v0.12.rc4](https://github.com/keypup-io/cloudtasker/tree/v0.12.rc4) (2021-03-29)
3
+ ## Latest RC [v0.12.rc5](https://github.com/keypup-io/cloudtasker/tree/v0.12.rc5) (2021-03-30)
4
4
 
5
- [Full Changelog](https://github.com/keypup-io/cloudtasker/compare/v0.11.0...v0.12.rc4)
5
+ [Full Changelog](https://github.com/keypup-io/cloudtasker/compare/v0.11.0...v0.12.rc5)
6
6
 
7
7
  **Improvements:**
8
8
  - ActiveJob: do not double log errors (ActiveJob has its own error logging)
@@ -10,6 +10,7 @@
10
10
  - Error logging: Do not log exception and stack trace separately, combine them instead.
11
11
  - Batch callbacks: Retry jobs when completion callback fails
12
12
  - Redis: Use Redis Sets instead of key pattern matching for listing methods (Cron jobs and Local Server)
13
+ - Batch progress: restrict calculation to direct children by default. Allow depth to be specified. Calculating progress using all tree jobs created significant delays on large batches.
13
14
 
14
15
  **Fixed bugs:**
15
16
  - Retries: Enforce job retry limit on job processing. There was an edge case where jobs could be retried indefinitely on batch callback errors.
data/docs/BATCH_JOBS.md CHANGED
@@ -84,8 +84,29 @@ You can access progression statistics in callback using `batch.progress`. See th
84
84
  E.g.
85
85
  ```ruby
86
86
  def on_batch_node_complete(_child_job)
87
- logger.info("Total: #{batch.progress.total}")
88
- logger.info("Completed: #{batch.progress.completed}")
89
- logger.info("Progress: #{batch.progress.percent.to_i}%")
87
+ progress = batch.progress
88
+ logger.info("Total: #{progress.total}")
89
+ logger.info("Completed: #{progress.completed}")
90
+ logger.info("Progress: #{progress.percent.to_i}%")
91
+ end
92
+ ```
93
+
94
+ **Since:** `v0.12.rc5`
95
+ By default the `progress` method only considers the direct child jobs to evaluate the batch progress. You can pass `depth: somenumber` to the `progress` method to calculate the actual batch progress in a more granular way. Be careful however that this method recursively calculates progress on the sub-batches and is therefore expensive.
96
+
97
+ E.g.
98
+ ```ruby
99
+ def on_batch_node_complete(_child_job)
100
+ # Considers the children for batch progress calculation
101
+ progress_0 = batch.progress # same as batch.progress(depth: 0)
102
+
103
+ # Considers the children and grand-children for batch progress calculation
104
+ progress_1 = batch.progress(depth: 1)
105
+
106
+ # Considers the children, grand-children and grand-grand-children for batch progress calculation
107
+ progress_2 = batch.progress(depth: 3)
108
+
109
+ logger.info("Progress: #{progress_1.percent.to_i}%")
110
+ logger.info("Progress: #{progress_2.percent.to_i}%")
90
111
  end
91
112
  ```
@@ -347,13 +347,20 @@ module Cloudtasker
347
347
  #
348
348
  # @return [Cloudtasker::Batch::BatchProgress] The batch progress.
349
349
  #
350
- def progress
350
+ def progress(depth: 0)
351
+ depth = depth.to_i
352
+
351
353
  # Capture batch state
352
354
  state = batch_state
353
355
 
354
- # Sum batch progress of current batch and all sub-batches
356
+ # Return immediately if we do not need to go down the tree
357
+ return BatchProgress.new(state) if depth <= 0
358
+
359
+ # Sum batch progress of current batch and sub-batches up to the specified
360
+ # depth
355
361
  state.to_h.reduce(BatchProgress.new(state)) do |memo, (child_id, child_status)|
356
- memo + (self.class.find(child_id)&.progress || BatchProgress.new(child_id => child_status))
362
+ memo + (self.class.find(child_id)&.progress(depth: depth - 1) ||
363
+ BatchProgress.new(child_id => child_status))
357
364
  end
358
365
  end
359
366
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cloudtasker
4
- VERSION = '0.12.rc4'
4
+ VERSION = '0.12.rc5'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudtasker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.rc4
4
+ version: 0.12.rc5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arnaud Lachaume
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-29 00:00:00.000000000 Z
11
+ date: 2021-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport