activejob-dispatch_rider 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/lib/activejob/dispatch_rider/handler_registrar_fallback.rb +16 -0
- data/lib/activejob/dispatch_rider/job_handler.rb +10 -0
- data/lib/activejob/dispatch_rider/version.rb +1 -1
- data/lib/activejob/dispatch_rider.rb +7 -4
- data/lib/activejob/queue_adapters/dispatch_rider_adapter.rb +2 -2
- data/spec/{dispatch_rider_active_job_handler_spec.rb → activejob/dispatch_rider/job_handler_spec.rb} +2 -2
- data/spec/activejob/queue_adapters/dispatch_rider_adapter_spec.rb +2 -1
- data/spec/dispatch_rider/registrars/handler_spec.rb +7 -0
- metadata +8 -5
- data/lib/dispatch_rider_active_job_handler.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2154aefe422c1bd365aa5539c0981fc5a2376011
|
4
|
+
data.tar.gz: 0c5b75841bd49d5970c3e38eca1be3644804dd91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e95b5deb170e20a1cbff1d003cb1aebf92db5d06b6811c343b1e4c389cae6453e3ce393c6dbf4d18209de0ae86c27a1c111bacf3047085c5be8d4cba421af5c
|
7
|
+
data.tar.gz: 0b101afa949ad24023667a1779b507164d5cb058b908d45cdc7a2fdbf7301f5ab9611499737b07409f7260c34be494d6193a45eb92b177245a53b3fc9d7cad31
|
data/README.md
CHANGED
@@ -139,3 +139,9 @@ CallAndWelcomeCustomer.perform_later Customer.find_by_name!("Smith"),
|
|
139
139
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
140
140
|
4. Push to the branch (`git push origin my-new-feature`)
|
141
141
|
5. Create a new Pull Request
|
142
|
+
|
143
|
+
## Contributors
|
144
|
+
|
145
|
+
Special thanks to those who contributed to this project. :smile:
|
146
|
+
|
147
|
+
* [@fredbaa](https://github.com/fredbaa)
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module ActiveJob
|
2
|
+
module DispatchRider
|
3
|
+
# This module is prepended to `DispatchRider::Registrars::Handler` to allow it to cover any
|
4
|
+
# ActiveJob messages. The assumption is that if the message's subject doesn't have a registered
|
5
|
+
# native `DispatchRider::Handler` then the job is delegated to
|
6
|
+
# `ActiveJob::DispatchRider::JobHandler`. `ActiveJob::DispatchRider::JobHandler` essentially
|
7
|
+
# just let ActiveJob process the message as it would process them normally.
|
8
|
+
module HandlerRegistrarFallback
|
9
|
+
def fetch(*)
|
10
|
+
super
|
11
|
+
rescue ::DispatchRider::NotRegistered
|
12
|
+
JobHandler
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -1,12 +1,15 @@
|
|
1
|
-
require "activejob/dispatch_rider/version"
|
2
1
|
require "active_job"
|
3
2
|
require "dispatch-rider"
|
4
|
-
require "dispatch_rider_active_job_handler"
|
5
3
|
|
6
4
|
module ActiveJob
|
7
5
|
module DispatchRider
|
8
|
-
# Your code goes here...
|
9
6
|
end
|
10
7
|
end
|
11
8
|
|
12
|
-
|
9
|
+
require_relative "dispatch_rider/version"
|
10
|
+
require_relative "dispatch_rider/job_handler"
|
11
|
+
require_relative "dispatch_rider/handler_registrar_fallback"
|
12
|
+
require_relative "queue_adapters/dispatch_rider_adapter"
|
13
|
+
|
14
|
+
# Handle all unregistered messages as messages coming from ActiveJobs.
|
15
|
+
DispatchRider::Registrars::Handler.prepend ActiveJob::DispatchRider::HandlerRegistrarFallback
|
@@ -7,8 +7,8 @@ module ActiveJob
|
|
7
7
|
def enqueue(job)
|
8
8
|
publisher.publish destinations: Array(job.queue_name),
|
9
9
|
message: {
|
10
|
-
subject:
|
11
|
-
body: job.serialize
|
10
|
+
subject: job.class.name.underscore,
|
11
|
+
body: job.serialize.merge(guid: job.job_id)
|
12
12
|
}
|
13
13
|
end
|
14
14
|
|
data/spec/{dispatch_rider_active_job_handler_spec.rb → activejob/dispatch_rider/job_handler_spec.rb}
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe ActiveJob::DispatchRider::JobHandler do
|
4
4
|
|
5
5
|
let!(:job_class) {
|
6
6
|
job_class = Class.new(ActiveJob::Base) do
|
@@ -27,7 +27,7 @@ describe DispatchRiderActiveJobHandler do
|
|
27
27
|
"_aj_symbol_keys" => ["foo"]
|
28
28
|
}
|
29
29
|
],
|
30
|
-
"guid" => "
|
30
|
+
"guid" => "8b71ac6b-2854-4287-8d1b-15085b70280b",
|
31
31
|
}
|
32
32
|
}
|
33
33
|
|
@@ -50,8 +50,9 @@ describe ActiveJob::QueueAdapters::DispatchRiderAdapter do
|
|
50
50
|
example("queued item") {
|
51
51
|
foo_job_class.perform_later foo: "bar"
|
52
52
|
|
53
|
-
expect(foo_queued_item["subject"]).to eq("
|
53
|
+
expect(foo_queued_item["subject"]).to eq("foo_aj_job")
|
54
54
|
expect(foo_queued_item["body"]["job_class"]).to eq("FooAjJob")
|
55
|
+
expect(foo_queued_item["body"]["guid"]).to eq(foo_queued_item["body"]["job_id"])
|
55
56
|
expect(foo_queued_item["body"]["queue_name"]).to eq("foo")
|
56
57
|
expect(foo_queued_item["body"]["arguments"].first).to include("foo" => "bar")
|
57
58
|
}
|
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: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ronald Maravilla
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-05-
|
12
|
+
date: 2015-05-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activejob
|
@@ -111,11 +111,13 @@ files:
|
|
111
111
|
- activejob-dispatch_rider.gemspec
|
112
112
|
- circle.yml
|
113
113
|
- lib/activejob/dispatch_rider.rb
|
114
|
+
- lib/activejob/dispatch_rider/handler_registrar_fallback.rb
|
115
|
+
- lib/activejob/dispatch_rider/job_handler.rb
|
114
116
|
- lib/activejob/dispatch_rider/version.rb
|
115
117
|
- lib/activejob/queue_adapters/dispatch_rider_adapter.rb
|
116
|
-
-
|
118
|
+
- spec/activejob/dispatch_rider/job_handler_spec.rb
|
117
119
|
- spec/activejob/queue_adapters/dispatch_rider_adapter_spec.rb
|
118
|
-
- spec/
|
120
|
+
- spec/dispatch_rider/registrars/handler_spec.rb
|
119
121
|
- spec/spec_helper.rb
|
120
122
|
homepage: https://github.com/payrollhero/activejob-dispatch_rider
|
121
123
|
licenses:
|
@@ -142,7 +144,8 @@ signing_key:
|
|
142
144
|
specification_version: 4
|
143
145
|
summary: "'ActiveJob::DispatchRider' adds `DispatchRider` support for `ActiveJob`."
|
144
146
|
test_files:
|
147
|
+
- spec/activejob/dispatch_rider/job_handler_spec.rb
|
145
148
|
- spec/activejob/queue_adapters/dispatch_rider_adapter_spec.rb
|
146
|
-
- spec/
|
149
|
+
- spec/dispatch_rider/registrars/handler_spec.rb
|
147
150
|
- spec/spec_helper.rb
|
148
151
|
has_rdoc:
|