dispatch-rider 1.1.7 → 1.2.0

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: 2cea57fa6cd7651b6a8efa077062611f5b37f4e9
4
- data.tar.gz: 27f2f2e08bab6dd3bf30a8a5fe446a8e575fe266
3
+ metadata.gz: 1a1ca3958470feda02b927f94698654ef9f9e803
4
+ data.tar.gz: 27e28265cf7227e992c0f35f1eb0ff3d8fb79a4d
5
5
  SHA512:
6
- metadata.gz: 0b0dda80035b75758d5a9c2525ae8d5192ec12f94679e3751df194788d665dcabc9fc7c3136388f61e3e741cd8312da99559baf580b22003ba30bc041978f5c2
7
- data.tar.gz: 8571ffb00c7ffbb78959c37fca5f6ff802d766ac74e52450b85b6789a1ec8a8f66d2d9fcaa85c441230a509bec36a782a8ab34b3111cb46a9849bbbc5cd2301c
6
+ metadata.gz: 997865accff6ed5df9b8ae28804be792c0cb30e679024d13b6e59624a705aa17285dc3ed566a251d17c18e57b21124f1594ee6045dd882983e11f13112943623
7
+ data.tar.gz: 811ca64e0a2d53a7172428e956605057d3d02b8674d5dc2b8bf78829e1c426db1673058ab68179c498cdfc9e9e8142392dcb75f4363d5654e789addd7e620c15
@@ -36,3 +36,5 @@ require "dispatch-rider/demultiplexer"
36
36
  require "dispatch-rider/runner"
37
37
  require "dispatch-rider/publisher"
38
38
  require "dispatch-rider/subscriber"
39
+
40
+ require "dispatch-rider/integrations/appsignal"
@@ -0,0 +1,44 @@
1
+ if defined? Appsignal
2
+ Appsignal.logger.info('Loading Dispatch Rider integration')
3
+
4
+ module DispatchRider
5
+ module Integrations
6
+ module Appsignal
7
+
8
+ def self.wrap_message(job, message)
9
+ begin
10
+ Appsignal::Transaction.create(SecureRandom.uuid, ENV.to_hash)
11
+
12
+ ActiveSupport::Notifications.instrument(
13
+ 'perform_job.dispatch-rider',
14
+ :class => message.subject,
15
+ :method => 'handle',
16
+ :attempts => message.receive_count,
17
+ :queue => message.queue_name,
18
+ :queue_time => (Time.now.to_f - message.sent_at.to_f) * 1000
19
+ ) do
20
+ job.call
21
+ end
22
+ rescue Exception => exception
23
+ unless Appsignal.is_ignored_exception?(exception)
24
+ Appsignal::Transaction.current.add_exception(exception)
25
+ end
26
+ raise exception
27
+ ensure
28
+ Appsignal::Transaction.current.complete!
29
+ end
30
+ end
31
+
32
+ end
33
+ end
34
+ end
35
+
36
+ DispatchRider.config do |config|
37
+
38
+ config.around(:dispatch_message) do |job, message|
39
+ DispatchRider::Appsignal.wrap_message(job, message)
40
+ end
41
+
42
+ end
43
+
44
+ end
@@ -27,7 +27,19 @@ module DispatchRider
27
27
  def return_to_queue
28
28
  extend_timeout(0)
29
29
  end
30
-
30
+
31
+ def receive_count
32
+ @item.approximate_receive_count
33
+ end
34
+
35
+ def sent_at
36
+ @item.sent_timestamp
37
+ end
38
+
39
+ def queue_name
40
+ queue.arn.split(':').last
41
+ end
42
+
31
43
  end
32
44
  end
33
45
  end
@@ -16,7 +16,19 @@ module DispatchRider
16
16
  def return_to_queue
17
17
  queue.put_back(item)
18
18
  end
19
-
19
+
20
+ def receive_count
21
+ 1 # can't really check that in this service
22
+ end
23
+
24
+ def sent_at
25
+ @item.ctime
26
+ end
27
+
28
+ def queue_name
29
+ File.basename(File.dirname(@item.path))
30
+ end
31
+
20
32
  end
21
33
  end
22
34
  end
@@ -20,6 +20,19 @@ module DispatchRider
20
20
  def return_to_queue
21
21
  raise NotImplementedError
22
22
  end
23
+
24
+ def receive_count
25
+ raise NotImplementedError
26
+ end
27
+
28
+ def sent_at
29
+ raise NotImplementedError
30
+ end
31
+
32
+ def queue_name
33
+ raise NotImplementedError
34
+ end
35
+
23
36
  end
24
37
  end
25
38
  end
@@ -1,4 +1,4 @@
1
1
  # This file specifies the current version of the gem.
2
2
  module DispatchRider
3
- VERSION = "1.1.7"
3
+ VERSION = "1.2.0"
4
4
  end
@@ -0,0 +1,13 @@
1
+ Description:
2
+ Generates a Publisher/Handler pair
3
+
4
+ Example:
5
+ rails generate dispatch_rider:job some_job
6
+
7
+ This will create:
8
+ app/publishers/some_job_publisher.rb
9
+ app/handlers/some_job.rb
10
+
11
+ As well as its tests (currently only supporting rspec):
12
+ spec/publishers/some_job_publisher_spec.rb
13
+ spec/handlers/some_job_spec.rb
@@ -0,0 +1,60 @@
1
+ class DispatchJob < Rails::Generators::Base
2
+
3
+ class Publisher < Rails::Generators::Base
4
+ source_root File.expand_path('../templates/publisher', __FILE__)
5
+ argument :handler_name, type: :string, required: true
6
+ argument :publisher_name, type: :string, required: true
7
+
8
+ class Rspec < Rails::Generators::Base
9
+ source_root File.expand_path('../templates/publisher', __FILE__)
10
+ argument :handler_name, type: :string, required: true
11
+ argument :publisher_name, type: :string, required: true
12
+
13
+ def generate_publisher_spec
14
+ template "publisher_spec.rb.erb", "spec/publishers/#{publisher_name}_spec.rb"
15
+ end
16
+ end
17
+
18
+ def generate_publisher
19
+ template "publisher.rb.erb", "app/publishers/#{publisher_name}.rb"
20
+ end
21
+
22
+ hook_for :test_framework, in: "dispatch_job:publisher"
23
+ end
24
+
25
+ class Handler < Rails::Generators::Base
26
+ source_root File.expand_path('../templates/handler', __FILE__)
27
+ argument :handler_name, type: :string, required: true
28
+
29
+ class Rspec < Rails::Generators::Base
30
+ source_root File.expand_path('../templates/handler', __FILE__)
31
+ argument :handler_name, type: :string, required: true
32
+
33
+ def generate_handler_spec
34
+ template "handler_spec.rb.erb", "spec/handlers/#{handler_name}_spec.rb"
35
+ end
36
+ end
37
+
38
+ def generate_handler
39
+ template "handler.rb.erb", "app/handlers/#{handler_name}.rb"
40
+ end
41
+
42
+ hook_for :test_framework, in: "dispatch_job:handler"
43
+ end
44
+
45
+ # source_root File.expand_path('../templates', __FILE__)
46
+
47
+ class_option :publisher, default: :publisher, hide: true
48
+ class_option :handler, default: :handler, hide: true
49
+
50
+ argument :handler_name, type: :string
51
+
52
+ hook_for :publisher do |publisher|
53
+ invoke publisher, [handler_name, handler_name.underscore + "_publisher"]
54
+ end
55
+
56
+ hook_for :handler do |handler|
57
+ invoke handler, [handler_name]
58
+ end
59
+
60
+ end
@@ -0,0 +1,9 @@
1
+ class <%= handler_name.classify %> < DispatchRider::Handlers::Base
2
+
3
+ # @param [Hash] attributes
4
+ def process(attributes)
5
+ #TODO: do something useful with this message
6
+ raise NotImplementedError
7
+ end
8
+
9
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe <%= handler_name.classify %> do
4
+
5
+ subject(:handler) { described_class.new }
6
+
7
+ # TODO: set some attributes
8
+ let(:attributes) { {} }
9
+
10
+ describe "#process" do
11
+ it "does something useful" do
12
+ handler.process attributes
13
+ # TODO: assert something
14
+ fail "not implemented"
15
+ end
16
+ end
17
+
18
+ end
@@ -0,0 +1,14 @@
1
+ class <%= publisher_name.classify %> < DispatchRider::Publisher::Base
2
+
3
+ # TODO: set the correct destination
4
+ destinations [:some_destination]
5
+ subject "<%= handler_name.underscore %>"
6
+
7
+ # TODO: accept some custom arguments here
8
+ # @return [<%= handler_name.classify %>]
9
+ def self.publish
10
+ # TODO: pass them to the message as hash arguments
11
+ new.publish({})
12
+ end
13
+
14
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe <%= publisher_name.classify %> do
4
+
5
+ describe '.process' do
6
+
7
+ # TODO: set up whatever needs to be set up
8
+
9
+ it "publishes the task" do
10
+ # TODO: assert the correct arguments
11
+ described_class.any_instance.should_receive(:publish).with()
12
+ # TODO: pass the right arguments
13
+ described_class.publish()
14
+ end
15
+
16
+ end
17
+
18
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dispatch-rider
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.7
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Suman Mukherjee
@@ -11,132 +11,132 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-02-06 00:00:00.000000000 Z
14
+ date: 2014-07-21 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport
18
18
  requirement: !ruby/object:Gem::Requirement
19
19
  requirements:
20
- - - '>='
20
+ - - ">="
21
21
  - !ruby/object:Gem::Version
22
22
  version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - '>='
27
+ - - ">="
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: activemodel
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  requirements:
34
- - - '>='
34
+ - - ">="
35
35
  - !ruby/object:Gem::Version
36
36
  version: '0'
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
- - - '>='
41
+ - - ">="
42
42
  - !ruby/object:Gem::Version
43
43
  version: '0'
44
44
  - !ruby/object:Gem::Dependency
45
45
  name: daemons
46
46
  requirement: !ruby/object:Gem::Requirement
47
47
  requirements:
48
- - - '>='
48
+ - - ">="
49
49
  - !ruby/object:Gem::Version
50
50
  version: '0'
51
51
  type: :runtime
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
54
54
  requirements:
55
- - - '>='
55
+ - - ">="
56
56
  - !ruby/object:Gem::Version
57
57
  version: '0'
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: bundler
60
60
  requirement: !ruby/object:Gem::Requirement
61
61
  requirements:
62
- - - '>='
62
+ - - ">="
63
63
  - !ruby/object:Gem::Version
64
64
  version: '0'
65
65
  type: :development
66
66
  prerelease: false
67
67
  version_requirements: !ruby/object:Gem::Requirement
68
68
  requirements:
69
- - - '>='
69
+ - - ">="
70
70
  - !ruby/object:Gem::Version
71
71
  version: '0'
72
72
  - !ruby/object:Gem::Dependency
73
73
  name: jeweler
74
74
  requirement: !ruby/object:Gem::Requirement
75
75
  requirements:
76
- - - ~>
76
+ - - "~>"
77
77
  - !ruby/object:Gem::Version
78
78
  version: 1.8.4
79
79
  type: :development
80
80
  prerelease: false
81
81
  version_requirements: !ruby/object:Gem::Requirement
82
82
  requirements:
83
- - - ~>
83
+ - - "~>"
84
84
  - !ruby/object:Gem::Version
85
85
  version: 1.8.4
86
86
  - !ruby/object:Gem::Dependency
87
87
  name: rake
88
88
  requirement: !ruby/object:Gem::Requirement
89
89
  requirements:
90
- - - '>='
90
+ - - ">="
91
91
  - !ruby/object:Gem::Version
92
92
  version: '0'
93
93
  type: :development
94
94
  prerelease: false
95
95
  version_requirements: !ruby/object:Gem::Requirement
96
96
  requirements:
97
- - - '>='
97
+ - - ">="
98
98
  - !ruby/object:Gem::Version
99
99
  version: '0'
100
100
  - !ruby/object:Gem::Dependency
101
101
  name: travis-lint
102
102
  requirement: !ruby/object:Gem::Requirement
103
103
  requirements:
104
- - - '>='
104
+ - - ">="
105
105
  - !ruby/object:Gem::Version
106
106
  version: '0'
107
107
  type: :development
108
108
  prerelease: false
109
109
  version_requirements: !ruby/object:Gem::Requirement
110
110
  requirements:
111
- - - '>='
111
+ - - ">="
112
112
  - !ruby/object:Gem::Version
113
113
  version: '0'
114
114
  - !ruby/object:Gem::Dependency
115
115
  name: rspec
116
116
  requirement: !ruby/object:Gem::Requirement
117
117
  requirements:
118
- - - '>='
118
+ - - "~>"
119
119
  - !ruby/object:Gem::Version
120
- version: '0'
120
+ version: '2.0'
121
121
  type: :development
122
122
  prerelease: false
123
123
  version_requirements: !ruby/object:Gem::Requirement
124
124
  requirements:
125
- - - '>='
125
+ - - "~>"
126
126
  - !ruby/object:Gem::Version
127
- version: '0'
127
+ version: '2.0'
128
128
  - !ruby/object:Gem::Dependency
129
- name: debugger
129
+ name: byebug
130
130
  requirement: !ruby/object:Gem::Requirement
131
131
  requirements:
132
- - - '>='
132
+ - - ">="
133
133
  - !ruby/object:Gem::Version
134
134
  version: '0'
135
135
  type: :development
136
136
  prerelease: false
137
137
  version_requirements: !ruby/object:Gem::Requirement
138
138
  requirements:
139
- - - '>='
139
+ - - ">="
140
140
  - !ruby/object:Gem::Version
141
141
  version: '0'
142
142
  description: Messaging system that is customizable based on which queueing system
@@ -152,6 +152,8 @@ extra_rdoc_files:
152
152
  - LICENSE.txt
153
153
  - README.md
154
154
  files:
155
+ - LICENSE.txt
156
+ - README.md
155
157
  - lib/dispatch-rider.rb
156
158
  - lib/dispatch-rider/callbacks.rb
157
159
  - lib/dispatch-rider/callbacks/access.rb
@@ -166,6 +168,7 @@ files:
166
168
  - lib/dispatch-rider/handlers/base.rb
167
169
  - lib/dispatch-rider/handlers/inheritance_tracking.rb
168
170
  - lib/dispatch-rider/handlers/named_process.rb
171
+ - lib/dispatch-rider/integrations/appsignal.rb
169
172
  - lib/dispatch-rider/message.rb
170
173
  - lib/dispatch-rider/notification_services.rb
171
174
  - lib/dispatch-rider/notification_services/aws_sns.rb
@@ -204,8 +207,12 @@ files:
204
207
  - lib/generators/dispatch_rider/install/USAGE
205
208
  - lib/generators/dispatch_rider/install/install_generator.rb
206
209
  - lib/generators/dispatch_rider/install/templates/script/dispatch_rider
207
- - LICENSE.txt
208
- - README.md
210
+ - lib/generators/dispatch_rider/job/USAGE
211
+ - lib/generators/dispatch_rider/job/dispatch_job_generator.rb
212
+ - lib/generators/dispatch_rider/job/templates/handler/handler.rb.erb
213
+ - lib/generators/dispatch_rider/job/templates/handler/handler_spec.rb.erb
214
+ - lib/generators/dispatch_rider/job/templates/publisher/publisher.rb.erb
215
+ - lib/generators/dispatch_rider/job/templates/publisher/publisher_spec.rb.erb
209
216
  homepage: https://github.com/payrollhero/dispatch-rider
210
217
  licenses:
211
218
  - MIT
@@ -216,17 +223,17 @@ require_paths:
216
223
  - lib
217
224
  required_ruby_version: !ruby/object:Gem::Requirement
218
225
  requirements:
219
- - - '>='
226
+ - - ">="
220
227
  - !ruby/object:Gem::Version
221
228
  version: '0'
222
229
  required_rubygems_version: !ruby/object:Gem::Requirement
223
230
  requirements:
224
- - - '>='
231
+ - - ">="
225
232
  - !ruby/object:Gem::Version
226
233
  version: '0'
227
234
  requirements: []
228
235
  rubyforge_project:
229
- rubygems_version: 2.0.14
236
+ rubygems_version: 2.3.0
230
237
  signing_key:
231
238
  specification_version: 4
232
239
  summary: Messaging system based on the reactor patter. You can publish messages to