acidic_job 1.0.0.beta.7 → 1.0.0.beta.10

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: 2ffcde3bd4dedc0b59de934bed0cadeaa63f33fb26f36ddf1678d17e0abbec55
4
- data.tar.gz: 8fe70548a2e2438e59956a41b2373f294150716a2d5e2de7e84993aeb766a523
3
+ metadata.gz: 6c2f5b13489acc0e87c1de14248857c107d794a60d0af9a3cafdc5606c80929c
4
+ data.tar.gz: 6bc97dda18375d3efd1cd37c7c6c2642b2cbe6c44a73e3451e07ebcce738ab30
5
5
  SHA512:
6
- metadata.gz: fcd0acb3acda0eeaaf499a58c165e376739d808d50f074e35f6236f5b0acdb55b34296b95f86a5edabb19b5c6c3e0e24a04e3408e62322052f43f538bcbc2433
7
- data.tar.gz: 46e5c1560717f18399afad20f568a69b8ee2c66aff02ba03f54d04f74dc2e749ad3aa5e5f73e470e22cb3a0737ac9f394498db558d4d806f7f453fb501b272f9
6
+ metadata.gz: 586158e2ccfa061f7efa636dd14ef9d83be1105d32e964e29a77df6728e941d8506379794e7144b8ec41f8c4e7187fae6de66cf7c37c16fd07d45a6e84bdb849
7
+ data.tar.gz: fdf9c926a74abc99262c76a508f07dd87de823958b5ea3230a5c6f98c17cb2f93153a32f8d34cb4c27145f0a5838a5e2090a32f815b7e8c61a50f7aafa65b39e
@@ -0,0 +1,13 @@
1
+ # These are supported funding model platforms
2
+
3
+ github: fractaledmind
4
+ patreon: # Replace with a single Patreon username
5
+ open_collective: # Replace with a single Open Collective username
6
+ ko_fi: # Replace with a single Ko-fi username
7
+ tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8
+ community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9
+ liberapay: # Replace with a single Liberapay username
10
+ issuehunt: # Replace with a single IssueHunt username
11
+ otechie: # Replace with a single Otechie username
12
+ lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
13
+ custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- acidic_job (1.0.0.beta.7)
4
+ acidic_job (1.0.0.beta.10)
5
5
  activejob
6
6
  activerecord
7
7
  activesupport
@@ -227,7 +227,7 @@ module AcidicJob
227
227
 
228
228
  # "STG__#{idempotency_key}__#{encoded_global_id}"
229
229
  _prefix, _idempotency_key, encoded_global_id = job_id.split("__")
230
- staged_job_gid = "gid://#{::Base64.decode64(encoded_global_id)}"
230
+ staged_job_gid = "gid://#{::Base64.urlsafe_decode64(encoded_global_id)}"
231
231
 
232
232
  @staged_job_run = ::GlobalID::Locator.locate(staged_job_gid)
233
233
  end
@@ -19,7 +19,7 @@ module AcidicJob
19
19
  if !@run.known_recovery_point?
20
20
  raise UnknownRecoveryPoint,
21
21
  "Defined workflow does not reference this step: #{@run.current_step_name.inspect}"
22
- elsif Array(awaited_jobs = jobs_from(@run.current_step_awaits)).compact.any?
22
+ elsif (awaited_jobs = jobs_from(@run.current_step_awaits)).any?
23
23
  # We only execute the current step, without progressing to the next step.
24
24
  # This ensures that any failures in parallel jobs will have this step retried in the main workflow
25
25
  step_result = @workflow.execute_current_step
@@ -65,10 +65,11 @@ module AcidicJob
65
65
  def jobs_from(jobs_or_jobs_getter)
66
66
  case jobs_or_jobs_getter
67
67
  when Array
68
- jobs_or_jobs_getter
68
+ jobs_or_jobs_getter.compact
69
69
  when Symbol, String
70
70
  if @job.respond_to?(jobs_or_jobs_getter, _include_private = true)
71
- @job.method(jobs_or_jobs_getter).call
71
+ jobs = @job.method(jobs_or_jobs_getter).call
72
+ Array(jobs).compact
72
73
  else
73
74
  raise UnknownAwaitedJob,
74
75
  "Invalid `awaits`; unknown method `#{jobs_or_jobs_getter}` for this job"
@@ -130,7 +130,7 @@ module AcidicJob
130
130
  # encode the identifier for this record in the job ID
131
131
  global_id = to_global_id.to_s.remove("gid://")
132
132
  # base64 encoding for minimal security
133
- encoded_global_id = Base64.encode64(global_id).strip
133
+ encoded_global_id = Base64.urlsafe_encode64(global_id, padding: false)
134
134
 
135
135
  [
136
136
  STAGED_JOB_ID_PREFIX,
@@ -174,7 +174,7 @@ module AcidicJob
174
174
  end
175
175
 
176
176
  def current_step_awaits
177
- current_step_hash.fetch("awaits", []) || []
177
+ current_step_hash["awaits"]
178
178
  end
179
179
 
180
180
  def next_step_finishes?
@@ -10,11 +10,11 @@ module AcidicJob
10
10
  return if json.nil? || json.empty?
11
11
 
12
12
  data = JSON.parse(json)
13
- Arguments.deserialize(data).first
13
+ Arguments.send :deserialize_argument, data
14
14
  end
15
15
 
16
16
  def dump(obj)
17
- data = Arguments.serialize [obj]
17
+ data = Arguments.send :serialize_argument, obj
18
18
  data.to_json
19
19
  rescue ActiveJob::SerializationError
20
20
  raise UnserializableValue
@@ -6,24 +6,16 @@ module AcidicJob
6
6
  module Serializers
7
7
  class JobSerializer < ::ActiveJob::Serializers::ObjectSerializer
8
8
  def serialize(job)
9
- super(job.serialize)
9
+ # don't serialize the `enqueued_at` value, as ActiveRecord will check if the Run record has changed
10
+ # by comparing the deserialized database value with a temporary in-memory generated value.
11
+ # That temporary in-memory generated value can sometimes have an `enqueued_at` value that is 1 second off
12
+ # from the original. In this case, ActiveRecord will think the record has unsaved changes and block the lock.
13
+ super(job.as_json.merge("job_class" => job.class.name))
10
14
  end
11
15
 
12
16
  def deserialize(hash)
13
- job = ActiveJob::Base.deserialize(hash)
17
+ job = ::ActiveJob::Base.deserialize(hash)
14
18
  job.send(:deserialize_arguments_if_needed)
15
- # this is a shim to ensure we can work with Ruby 2.7 as well as 3.0+
16
- # :nocov:
17
- if job.arguments.last.is_a?(Hash)
18
- *args, kwargs = job.arguments
19
- else
20
- args = job.arguments
21
- kwargs = {}
22
- end
23
- # :nocov:
24
- job.instance_variable_set(:@__acidic_job_args, args)
25
- job.instance_variable_set(:@__acidic_job_kwargs, kwargs)
26
-
27
19
  job
28
20
  end
29
21
 
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "./testing"
4
+
5
+ module AcidicJob
6
+ class TestCase < ::ActiveJob::TestCase
7
+ include ::AcidicJob::Testing
8
+ end
9
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AcidicJob
4
- VERSION = "1.0.0.beta.7"
4
+ VERSION = "1.0.0.beta.10"
5
5
  end
@@ -50,10 +50,6 @@ module AcidicJob
50
50
  wrapped_method = WorkflowStep.new(run: @run, job: @job).wrapped
51
51
  current_step = @run.current_step_name
52
52
 
53
- # can't reproduce yet, but saw a bug in production where
54
- # nested awaits workflows had an unsaved `workflow` attribute
55
- @run.save! if @run.has_changes_to_save?
56
-
57
53
  AcidicJob.logger.log_run_event("Executing #{current_step}...", @job, @run)
58
54
  @run.with_lock do
59
55
  @step_result = wrapped_method.call(@run)
@@ -64,10 +60,6 @@ module AcidicJob
64
60
  def run_step_result
65
61
  next_step = @run.next_step_name
66
62
 
67
- # can't reproduce yet, but saw a bug in production where
68
- # nested awaits workflows had an unsaved `workflow` attribute
69
- @run.save! if @run.has_changes_to_save?
70
-
71
63
  AcidicJob.logger.log_run_event("Progressing to #{next_step}...", @job, @run)
72
64
  @run.with_lock do
73
65
  @step_result.call(run: @run)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acidic_job
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta.7
4
+ version: 1.0.0.beta.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - fractaledmind
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-10 00:00:00.000000000 Z
11
+ date: 2022-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activejob
@@ -227,6 +227,7 @@ executables: []
227
227
  extensions: []
228
228
  extra_rdoc_files: []
229
229
  files:
230
+ - ".github/FUNDING.yml"
230
231
  - ".github/workflows/main.yml"
231
232
  - ".gitignore"
232
233
  - ".rubocop.yml"
@@ -271,6 +272,7 @@ files:
271
272
  - lib/acidic_job/serializers/range_serializer.rb
272
273
  - lib/acidic_job/serializers/recovery_point_serializer.rb
273
274
  - lib/acidic_job/serializers/worker_serializer.rb
275
+ - lib/acidic_job/test_case.rb
274
276
  - lib/acidic_job/testing.rb
275
277
  - lib/acidic_job/version.rb
276
278
  - lib/acidic_job/workflow.rb