sidekiq-sequence 0.1.0 → 0.1.5

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: c624a6fd72d24ee9e41f0efc66acbab3ae57fc99ddc38121c76b25f34b2dbf95
4
- data.tar.gz: 7af58740782a790349cfcb31416eda672310782887270e5709c905b6f3d5f518
3
+ metadata.gz: 9651141aaf29a94360df739c7a16272b19b3ced0b6cf25ff56ea897b021952af
4
+ data.tar.gz: badd2b56cb8be4a5bbfb147851c73f10c0bae36939f0dcc1fc2f5538dd68dde5
5
5
  SHA512:
6
- metadata.gz: 98b0ec2a669b2b8b632f00494b48aa5e3a953e297b4ca09fd5f5402c763f96c1ae441e9276ab37d139bbbd71fb4b937a0e546ca92bafadfe0dd00f6c25e841e0
7
- data.tar.gz: 295b926a199219d4b9a0f8df2e877ab0a9aedd658fe4afc40bc1d9c01055d8fd6a04cdf0461fb3a0e8dcd476a8ad3f7e19e4ea7288eb3a8b58ae28e06829bbde
6
+ metadata.gz: b40ba6749f55b6f28003e85a242a157ab709947159444795302dd51d4e3b5547c94befd5c6e0e20ea88a582f314440b33f8394fa76fee09ce33ea519884fa0c2
7
+ data.tar.gz: a316aafe5e4688dc9307ebd19896e59a0f3a3a9efc73fcbbf66d3572935cc13250c2d654f813ec74e2e05cf9e3b303092e06a1b79b51b0d4ba3bfaccd823b52c
data/README.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # Sidekiq::Sequence - Sequential Sidekiq jobs.
2
2
 
3
- Sidekiq is awesome, but it doesn't provide any support for sequential jobs, where a sequence of jobs must be run in a set order. Sidekiq::Sequence provides a simple but powerful framework to run a sequence of Sidekiq jobs.
3
+ Sidekiq is awesome, but it doesn't provide any support for sequential jobs, where a sequence of jobs must be run in a set order.
4
4
 
5
- Sidekiq::Sequence is currently only intended for use in Rails applications.
5
+ Sidekiq::Sequence provides a simple yet powerful framework to run a sequence of Sidekiq jobs, where each job runs only when the previous job successfully completes. It relies on Sidekiq's retry functionality to handle failed jobs. So if a job fails, any subsequent jobs will not run. Once the job is retried and is successful, the next job will start.
6
+
7
+ > **NOTE:** Sidekiq::Sequence is currently only intended for use in Rails applications.
6
8
 
7
9
  ## Installation
8
10
 
@@ -4,4 +4,6 @@ class Sidekiq::Sequence::Record < ApplicationRecord
4
4
  def self.table_name_prefix
5
5
  'sidekiq_sequence_'
6
6
  end
7
+
8
+ serialize :data, JSON unless connection.adapter_name =~ /postg|mysql/i
7
9
  end
@@ -19,6 +19,17 @@ module SidekiqSequence
19
19
  def migration_version
20
20
  "[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]"
21
21
  end
22
+
23
+ def properties_type
24
+ case ActiveRecord::Base.connection_config[:adapter].to_s
25
+ when /postg/i # postgres, postgis
26
+ 'jsonb'
27
+ when /mysql/i
28
+ 'json'
29
+ else
30
+ 'text'
31
+ end
32
+ end
22
33
  end
23
34
  end
24
35
  end
@@ -1,7 +1,7 @@
1
1
  class <%= migration_class_name %> < ActiveRecord::Migration<%= migration_version %>
2
2
  def change
3
3
  create_table :sidekiq_sequence_records do |t|
4
- t.jsonb :data, default: {}
4
+ t.<%= properties_type %> :data
5
5
  t.integer :current_step, default: 0
6
6
  t.timestamps
7
7
  end
@@ -7,7 +7,12 @@ module Sidekiq
7
7
  @@steps = []
8
8
 
9
9
  def self.step(worker_class)
10
- @@steps << worker_class
10
+ klass = worker_class.name
11
+ @@steps << klass unless @@steps.include?(klass)
12
+ end
13
+
14
+ def self.steps
15
+ @@steps
11
16
  end
12
17
 
13
18
  def self.perform_step(index, id)
@@ -15,7 +20,7 @@ module Sidekiq
15
20
  # No more steps in the sequence, so delete the record.
16
21
  Record.destroy id
17
22
  else
18
- @@steps[index].perform_async id
23
+ @@steps[index].constantize.perform_async id
19
24
  end
20
25
  end
21
26
 
@@ -23,7 +28,7 @@ module Sidekiq
23
28
  record = Record.create(data: data)
24
29
 
25
30
  # Start first job in the sequence.
26
- @@steps.first.perform_async record.id
31
+ @@steps.first.constantize.perform_async record.id
27
32
  end
28
33
  end
29
34
  # rubocop:enable Style/ClassVars
@@ -9,7 +9,10 @@ module Sidekiq
9
9
 
10
10
  super(*args)
11
11
 
12
- @record.increment(:current_step).save!
12
+ # Increment the step and update data attribute.
13
+ @record.increment(:current_step)
14
+ @record.data = @data
15
+ @record.save!
13
16
 
14
17
  # Perform the next in sequence.
15
18
  self.class.parent.perform_step @record.current_step, @record.id
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sidekiq
4
4
  module Sequence
5
- VERSION = '0.1.0'
5
+ VERSION = '0.1.5'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-sequence
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Moss
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-12 00:00:00.000000000 Z
11
+ date: 2020-06-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Create and manage sequential jobs in Sidekiq
14
14
  email: