acidic_job 1.0.0.rc6 → 1.0.0.rc7

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: '004839711b3d3c8bec8ab08dec1d4c5c855fa4f69f659b9c220c151d5003d6d4'
4
- data.tar.gz: 46dd79d7e3a83c019dd449c3846986c358b8f572ba3b2ca811087cd567e105e2
3
+ metadata.gz: 6583544dc3b3545721d81facda79a461cb8a3a7a8078d2dc309dbc887c0dc1a7
4
+ data.tar.gz: 89f94171898b64372b85b6dcca3c4f6134e608f39c4aadeb8a776ce7c1a6e294
5
5
  SHA512:
6
- metadata.gz: ba94864fc9c8b710959bd21ec0f53d4a42bacce974e5d985d92060ffe3215102889573dc5b04bbe697a03506df7c270d20fbfc73d5316e04b977c2d47f0588b8
7
- data.tar.gz: caee8a65b86e58266730487f52185b9c5dcb64801f6db241b8ffa256d8d741ea9668a673371bdca1da806cc8dff8c62f742a69f86086442dac4b64d63649ec52
6
+ metadata.gz: 25fb20afe5782e1e73f23c2c020948ba732f25e9abb9cf32dcc5803eb74fa7f3c3bb4e674aaf6bd80263d235251fc043b5ee23f2176cdb0b2e99397c1e74ef7a
7
+ data.tar.gz: a09e720a54df383804b54d63b1acf8bd6b2bc912e05dea373f2912b87bbaa5f4e7e60413491ae13e4c780ba99e5cc842e73774837a08dbc87d8e223502534a70
data/README.md CHANGED
@@ -183,7 +183,7 @@ class Job < ActiveJob::Base
183
183
  ```
184
184
 
185
185
  > [!TIP]
186
- > You should think carefully about what constitutes a unique execution of a workflow. Imagine you had a workflow job for balance transers. Jill transfers $10 to John. Your system **must** be able to differentiate between retries of this transfer and new independent transfers. If you were only to use the `sender`, `recipient`, and `amount` as your `unique_by` values, then if Jill tries to transfer another $10 to John at some point in the future, that work will be considered a retry of the first transfer and not a new transfer.
186
+ > You should think carefully about what constitutes a unique execution of a workflow. Imagine you had a workflow job for balance transfers. Jill transfers $10 to John. Your system **must** be able to differentiate between retries of this transfer and new independent transfers. If you were only to use the `sender`, `recipient`, and `amount` as your `unique_by` values, then if Jill tries to transfer another $10 to John at some point in the future, that work will be considered a retry of the first transfer and not a new transfer.
187
187
 
188
188
 
189
189
  ### Orchestrating steps
@@ -26,14 +26,20 @@ module AcidicJob
26
26
  require_relative "serializers/exception_serializer"
27
27
  require_relative "serializers/new_record_serializer"
28
28
  require_relative "serializers/job_serializer"
29
- require_relative "serializers/range_serializer"
30
-
31
- ActiveJob::Serializers.add_serializers(
32
- Serializers::ExceptionSerializer,
33
- Serializers::NewRecordSerializer,
34
- Serializers::JobSerializer,
35
- Serializers::RangeSerializer
36
- )
29
+
30
+ serializers = [
31
+ Serializers::ExceptionSerializer.instance,
32
+ Serializers::NewRecordSerializer.instance,
33
+ Serializers::JobSerializer.instance
34
+ ]
35
+
36
+ # Rails 7.1+ includes a RangeSerializer, so only add ours for older versions
37
+ unless defined?(ActiveJob::Serializers::RangeSerializer)
38
+ require_relative "serializers/range_serializer"
39
+ serializers << Serializers::RangeSerializer.instance
40
+ end
41
+
42
+ ActiveJob::Serializers.add_serializers(*serializers)
37
43
  end
38
44
  end
39
45
 
@@ -26,6 +26,10 @@ module AcidicJob
26
26
  def serialize?(argument)
27
27
  defined?(Exception) && argument.is_a?(Exception)
28
28
  end
29
+
30
+ def klass
31
+ ::Exception
32
+ end
29
33
  end
30
34
  end
31
35
  end
@@ -22,6 +22,10 @@ module AcidicJob
22
22
  def serialize?(argument)
23
23
  defined?(::ActiveJob::Base) && argument.class < ::ActiveJob::Base
24
24
  end
25
+
26
+ def klass
27
+ ::ActiveJob::Base
28
+ end
25
29
  end
26
30
  end
27
31
  end
@@ -20,6 +20,10 @@ module AcidicJob
20
20
  def serialize?(argument)
21
21
  defined?(::ActiveRecord) && argument.respond_to?(:new_record?) && argument.new_record?
22
22
  end
23
+
24
+ def klass
25
+ ::ActiveRecord::Base
26
+ end
23
27
  end
24
28
  end
25
29
  end
@@ -2,25 +2,25 @@
2
2
 
3
3
  require "active_job/serializers/object_serializer"
4
4
 
5
- # :nocov:
6
5
  module AcidicJob
7
6
  module Serializers
7
+ # This serializer is only used for Rails versions prior to 7.1,
8
+ # which introduced ActiveJob::Serializers::RangeSerializer.
8
9
  class RangeSerializer < ::ActiveJob::Serializers::ObjectSerializer
9
10
  KEYS = %w[begin end exclude_end].freeze
10
11
 
11
12
  def serialize(range)
12
- args = Arguments.serialize([ range.begin, range.end, range.exclude_end? ])
13
+ args = ::ActiveJob::Arguments.serialize([range.begin, range.end, range.exclude_end?])
13
14
  super(KEYS.zip(args).to_h)
14
15
  end
15
16
 
16
17
  def deserialize(hash)
17
- klass.new(*Arguments.deserialize(hash.values_at(*KEYS)))
18
+ klass.new(*::ActiveJob::Arguments.deserialize(hash.values_at(*KEYS)))
18
19
  end
19
20
 
20
- private def klass
21
+ def klass
21
22
  ::Range
22
23
  end
23
24
  end
24
25
  end
25
26
  end
26
- # :nocov:
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AcidicJob
4
- VERSION = "1.0.0.rc6"
4
+ VERSION = "1.0.0.rc7"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acidic_job
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc6
4
+ version: 1.0.0.rc7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Margheim