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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ad8cd41d0e457743dd03943aba4efc40af19e52c
4
- data.tar.gz: 5e59ba98d4aa917747e82772361b46ab3b3e3fd0
3
+ metadata.gz: 2154aefe422c1bd365aa5539c0981fc5a2376011
4
+ data.tar.gz: 0c5b75841bd49d5970c3e38eca1be3644804dd91
5
5
  SHA512:
6
- metadata.gz: 47b37f3ba16b43eb15f8fbbbf22303befdc0064e940d78ea5893c45ed8685c4adfce13caaf5e155b702d4f1cb276fa99aaefb99af58476dbb989cde3677a9599
7
- data.tar.gz: 10c278700fc385c817c430e0f9a5ad6bb87b689674b4d7bdac4179288a20839759e085f0eb8fd8daee401c2f3664c423dbcbc48b042895510ed110764291dce4
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
@@ -0,0 +1,10 @@
1
+ module ActiveJob
2
+ module DispatchRider
3
+ # Generic DispatchRider handler for ActiveJob.
4
+ class JobHandler < ::DispatchRider::Handlers::Base
5
+ def process(job_data)
6
+ ::ActiveJob::Base.execute job_data
7
+ end
8
+ end
9
+ end
10
+ end
@@ -1,5 +1,5 @@
1
1
  module ActiveJob
2
2
  module DispatchRider
3
- VERSION = "1.0.0"
3
+ VERSION = "1.0.1"
4
4
  end
5
5
  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
- require "activejob/queue_adapters/dispatch_rider_adapter"
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: "dispatch_rider_active_job_handler",
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
 
@@ -1,6 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
- describe DispatchRiderActiveJobHandler do
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" => "d9188320-580d-481f-a579-c3c521beccb8",
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("dispatch_rider_active_job_handler")
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
  }
@@ -0,0 +1,7 @@
1
+ require "spec_helper"
2
+
3
+ describe DispatchRider::Registrars::Handler do
4
+ subject(:registrar) { described_class.new }
5
+
6
+ example { expect(registrar.fetch "foo").to eq ActiveJob::DispatchRider::JobHandler }
7
+ 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: 1.0.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-09 00:00:00.000000000 Z
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
- - lib/dispatch_rider_active_job_handler.rb
118
+ - spec/activejob/dispatch_rider/job_handler_spec.rb
117
119
  - spec/activejob/queue_adapters/dispatch_rider_adapter_spec.rb
118
- - spec/dispatch_rider_active_job_handler_spec.rb
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/dispatch_rider_active_job_handler_spec.rb
149
+ - spec/dispatch_rider/registrars/handler_spec.rb
147
150
  - spec/spec_helper.rb
148
151
  has_rdoc:
@@ -1,6 +0,0 @@
1
- # Generic DispatchRider handler for ActiveJob.
2
- class DispatchRiderActiveJobHandler < DispatchRider::Handlers::Base
3
- def process(job_data)
4
- ::ActiveJob::Base.execute job_data
5
- end
6
- end