chained_job 0.6.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 818800b980eebd353e45811df72d640740f5fc2e5cd994f5d3e1297151e4c0b8
4
- data.tar.gz: 11262d0b15f247b32db77e76590186aabe332e39f9dabef876e2db015bb3f714
3
+ metadata.gz: 627fdbd88729785e5f036aa8eead67eba9e829ab8fff3fa7d7792249a9dcea0e
4
+ data.tar.gz: d3e9721bfae1f4676428d73a3efba5c417c89527f2750de10ef859c0846e567e
5
5
  SHA512:
6
- metadata.gz: 1d3598a379c3e8a19cd16e1004cca085a6736f258173c918d0d39a8bd4b7a0cfd283797fc3412d017dbde0efcb2080595344f01ba358ff421cd5e2a1b6e754e3
7
- data.tar.gz: d144c5e5f36895ca6d80eb2d8df85a52149036d2b3cffd6829e9ffb37d89c5615f7b074996d6c0237f32eedcdf031baf24fc7788aeba073cb3bf6bc81c6f1a9f
6
+ metadata.gz: cadabdd000cb69d656b930d0ad960af23901634c02725e6299669aa963ec9e0d732b98d6adce7785d1b1f37b8e0bab4453fa7b6ed558dbe208d7bbe07d3a7d95
7
+ data.tar.gz: c1b8e3ed98fe248078ac19bcc07db5c0a04bd2b747fb6b88f43698835a6da805db33b7b36685d5a38432fc42613e329418080035e564b1b95c56c946b9cafc5f
@@ -15,5 +15,9 @@ module ChainedJob
15
15
  def tag_list(prefix)
16
16
  "#{prefix}:tags"
17
17
  end
18
+
19
+ def serialize(arguments)
20
+ arguments.map { |argument| Marshal.dump(argument) }
21
+ end
18
22
  end
19
23
  end
@@ -22,13 +22,22 @@ module ChainedJob
22
22
  with_hooks do
23
23
  return finished_worker unless argument
24
24
 
25
- job_instance.process(argument)
25
+ begin
26
+ job_instance.process(argument)
27
+ rescue StandardError => e
28
+ push_job_arguments_back if handle_retry?
29
+ raise e
30
+ end
26
31
  job_instance.class.perform_later(args, worker_id, job_tag)
27
32
  end
28
33
  end
29
34
 
30
35
  private
31
36
 
37
+ def handle_retry?
38
+ job_instance.try(:handle_retry?)
39
+ end
40
+
32
41
  def with_hooks
33
42
  ChainedJob.config.around_chain_process.call(options) { yield }
34
43
  end
@@ -72,5 +81,9 @@ module ChainedJob
72
81
  def job_key
73
82
  Helpers.job_key(job_arguments_key)
74
83
  end
84
+
85
+ def push_job_arguments_back
86
+ ChainedJob.redis.rpush(redis_key, Helpers.serialize([argument]))
87
+ end
75
88
  end
76
89
  end
@@ -20,7 +20,7 @@ module ChainedJob
20
20
  set_tag_list
21
21
 
22
22
  array_of_job_arguments.each_slice(config.arguments_batch_size) do |sublist|
23
- ChainedJob.redis.rpush(redis_key, serialize(sublist))
23
+ ChainedJob.redis.rpush(redis_key, Helpers.serialize(sublist))
24
24
  end
25
25
 
26
26
  ChainedJob.redis.expire(redis_key, config.arguments_queue_expiration)
@@ -44,10 +44,6 @@ module ChainedJob
44
44
  @job_key ||= Helpers.job_key(job_arguments_key)
45
45
  end
46
46
 
47
- def serialize(arguments)
48
- arguments.map { |argument| Marshal.dump(argument) }
49
- end
50
-
51
47
  def config
52
48
  ChainedJob.config
53
49
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ChainedJob
4
- VERSION = '0.6.1'
4
+ VERSION = '0.7.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chained_job
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mantas Kūjalis
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-06-10 00:00:00.000000000 Z
12
+ date: 2021-08-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler