activejob-dispatch_rider 1.0.1 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.travis.yml +11 -0
- data/activejob-dispatch_rider.gemspec +3 -3
- data/lib/activejob/dispatch_rider/version.rb +1 -1
- data/lib/activejob/queue_adapters/dispatch_rider_adapter.rb +17 -12
- data/spec/activejob/queue_adapters/dispatch_rider_adapter_spec.rb +8 -3
- data/spec/spec_helper.rb +17 -2
- metadata +13 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1177fb40b9c1e4225b9e42babbbfd6eb8ca05259d04f3c73f61926eea62b2928
|
4
|
+
data.tar.gz: 1dcc9a40be6b705b040974e1a2016713075357a318a1a36d2b167e10944961cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '081c5ce0e5a21f2c698118fef332d72573cdd739a08863edcc7eb69240c4d07d7cbc0d0bdfe9fc1170a01de06e12cf305cac8737c5a335744a0568bf92729649'
|
7
|
+
data.tar.gz: 57242fe4bd83b161dbee694ace25e1edb222541985b61a1784fdff8d17bc0d0cabc6129372d4555a101a7537522022115abcce533823db8d831b2708f9ee4e1c
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
@@ -18,10 +18,10 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency "activejob"
|
22
|
-
spec.add_dependency "dispatch-rider"
|
21
|
+
spec.add_dependency "activejob", '~> 5.2.0'
|
22
|
+
spec.add_dependency "dispatch-rider", "~> 1.7"
|
23
23
|
spec.add_development_dependency "bundler", "~> 1.7"
|
24
24
|
spec.add_development_dependency "rake", "~> 10.0"
|
25
25
|
spec.add_development_dependency "rspec"
|
26
|
-
spec.add_development_dependency "
|
26
|
+
spec.add_development_dependency "sqlite3"
|
27
27
|
end
|
@@ -2,21 +2,17 @@ module ActiveJob
|
|
2
2
|
module QueueAdapters
|
3
3
|
# Adds support for DispatchRider to ActiveJob.
|
4
4
|
class DispatchRiderAdapter
|
5
|
-
class << self
|
6
5
|
# @param [ActiveJob::Base] job
|
7
6
|
def enqueue(job)
|
8
|
-
publisher.publish
|
9
|
-
message: {
|
10
|
-
subject: job.class.name.underscore,
|
11
|
-
body: job.serialize.merge(guid: job.job_id)
|
12
|
-
}
|
7
|
+
publisher.publish job_details_for(job)
|
13
8
|
end
|
14
9
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
10
|
+
# @param [ActiveJob::Base] job
|
11
|
+
# @param [Float] scheduled_at - float representing time (blame AJ)
|
12
|
+
def enqueue_at(job, scheduled_at)
|
13
|
+
scheduled_job_details = job_details_for(job).merge(scheduled_at: Time.at(scheduled_at))
|
14
|
+
|
15
|
+
::DispatchRider::ScheduledJob.create! scheduled_job_details
|
20
16
|
end
|
21
17
|
|
22
18
|
private
|
@@ -24,7 +20,16 @@ module ActiveJob
|
|
24
20
|
def publisher
|
25
21
|
@publisher ||= ::DispatchRider::Publisher.new
|
26
22
|
end
|
27
|
-
|
23
|
+
|
24
|
+
def job_details_for(job)
|
25
|
+
{
|
26
|
+
destinations: Array(job.queue_name),
|
27
|
+
message: {
|
28
|
+
subject: job.class.name.underscore,
|
29
|
+
body: job.serialize.merge(guid: job.job_id)
|
30
|
+
}
|
31
|
+
}
|
32
|
+
end
|
28
33
|
end
|
29
34
|
end
|
30
35
|
end
|
@@ -65,10 +65,15 @@ describe ActiveJob::QueueAdapters::DispatchRiderAdapter do
|
|
65
65
|
end
|
66
66
|
|
67
67
|
describe ".enqueue_at" do
|
68
|
-
let(:
|
69
|
-
let(:timestamp) { Time.now }
|
68
|
+
let(:tomorrow_midnight) { Date.tomorrow.midnight }
|
70
69
|
|
71
|
-
example {
|
70
|
+
example {
|
71
|
+
expect {
|
72
|
+
foo_job_class.set(wait_until: tomorrow_midnight).perform_later foo: "bar"
|
73
|
+
}.to change(DispatchRider::ScheduledJob, :count).by 1
|
74
|
+
|
75
|
+
expect(DispatchRider::ScheduledJob.last.scheduled_at).to eq tomorrow_midnight
|
76
|
+
}
|
72
77
|
end
|
73
78
|
end
|
74
79
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
require "
|
2
|
-
CodeClimate::TestReporter.start
|
1
|
+
require "sqlite3"
|
3
2
|
|
4
3
|
require "activejob/dispatch_rider"
|
5
4
|
|
@@ -109,4 +108,20 @@ RSpec.configure do |config|
|
|
109
108
|
# as the one that triggered the failure.
|
110
109
|
Kernel.srand config.seed
|
111
110
|
=end
|
111
|
+
|
112
|
+
config.before(:suite) do
|
113
|
+
FileUtils.mkdir_p "tmp"
|
114
|
+
FileUtils.rm_f "tmp/lite.db"
|
115
|
+
FileUtils.rm_rf "spectmp"
|
116
|
+
SQLite3::Database.new "tmp/lite.db"
|
117
|
+
ActiveRecord::Base.establish_connection adapter: :sqlite3, database: File.dirname(__FILE__) + "tmp/lite.db"
|
118
|
+
ActiveRecord::Schema.define(version: 1) do
|
119
|
+
extend DispatchRider::ScheduledJob::Migration
|
120
|
+
create_scheduled_jobs_table
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
config.after do
|
125
|
+
DispatchRider::ScheduledJob.destroy_all
|
126
|
+
end
|
112
127
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activejob-dispatch_rider
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ronald Maravilla
|
@@ -9,36 +9,36 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-08-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activejob
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
18
|
+
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
20
|
+
version: 5.2.0
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - "
|
25
|
+
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
27
|
+
version: 5.2.0
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: dispatch-rider
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- - "
|
32
|
+
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
34
|
+
version: '1.7'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- - "
|
39
|
+
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
41
|
+
version: '1.7'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: bundler
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -82,7 +82,7 @@ dependencies:
|
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
|
-
name:
|
85
|
+
name: sqlite3
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
88
|
- - ">="
|
@@ -105,6 +105,7 @@ extra_rdoc_files: []
|
|
105
105
|
files:
|
106
106
|
- ".gitignore"
|
107
107
|
- ".rspec"
|
108
|
+
- ".travis.yml"
|
108
109
|
- Gemfile
|
109
110
|
- README.md
|
110
111
|
- Rakefile
|
@@ -138,8 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
139
|
- !ruby/object:Gem::Version
|
139
140
|
version: '0'
|
140
141
|
requirements: []
|
141
|
-
|
142
|
-
rubygems_version: 2.2.2
|
142
|
+
rubygems_version: 3.0.9
|
143
143
|
signing_key:
|
144
144
|
specification_version: 4
|
145
145
|
summary: "'ActiveJob::DispatchRider' adds `DispatchRider` support for `ActiveJob`."
|
@@ -148,4 +148,3 @@ test_files:
|
|
148
148
|
- spec/activejob/queue_adapters/dispatch_rider_adapter_spec.rb
|
149
149
|
- spec/dispatch_rider/registrars/handler_spec.rb
|
150
150
|
- spec/spec_helper.rb
|
151
|
-
has_rdoc:
|