harness-action_subscriber 0.0.2 → 0.0.3

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
- SHA1:
3
- metadata.gz: b2b2a51da3fe190bf92c77eb6b2b6fd0706ad912
4
- data.tar.gz: 27744d06d62b8af871048a124e14b222080f5dfb
2
+ SHA256:
3
+ metadata.gz: '04483ecd6328ff52f81134722162f4fd666ec7009caca930140cee966b22f667'
4
+ data.tar.gz: 2464d449ec0d22076c8d0ffa245890a23d1c34c894194b23d42d4af8a6a72d01
5
5
  SHA512:
6
- metadata.gz: e4f50700f10e6c081288f2b5b1272eda29b8914277a26b17b464a6b695445f693b962a9957df19f38909ae5134b3a5da18ff161e605e19080b5c7e07d69a0cdf
7
- data.tar.gz: 071e9cb0806d3518e499e6841793b0fcf09cdd3efcbff70299a1925c39d95d7d42042a7f0f1e0e69f5e2d8fc3091cb594442745f78dfcd1dd8945c8b2d16cb8a
6
+ metadata.gz: eda2427b07a8dc80b40325f8b799c6bbe8b19ee95f6d161023666b286ffdfc484a4d1aabe3d0b7ee22db608dd8f43374c1ea104dab84da8f6b71e985071b277f
7
+ data.tar.gz: 4569346b1aeb5396027003936479c6cdff06a2907f41846d570b833ef8d87af9b78d32e529b63d88dc6b1464552e75392b6004503895ecd232048bb740ea0ea3
data/.gitignore CHANGED
@@ -20,3 +20,6 @@ tmp
20
20
  *.o
21
21
  *.a
22
22
  mkmf.log
23
+
24
+ # respec failure tracking
25
+ .rspec_status
@@ -20,7 +20,9 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.10"
22
22
  spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec", "~> 3.0"
23
24
 
25
+ spec.add_runtime_dependency "activesupport", ">= 3.2"
24
26
  spec.add_runtime_dependency "harness", ">= 2.0.0"
25
27
  spec.add_runtime_dependency "action_subscriber", ">= 2.0.0"
26
28
  end
@@ -1,5 +1,29 @@
1
1
  require "harness/action_subscriber/version"
2
2
 
3
+ require "harness"
4
+ require "active_support"
5
+
6
+ ::ActiveSupport::Notifications.subscribe "message_acked.action_subscriber" do |*args|
7
+ event = ::ActiveSupport::Notifications::Event.new(*args)
8
+ event_name = event.payload[:queue].gsub(".", "-")
9
+ ::Harness.increment "action_subscriber.messages_acked.#{event_name}"
10
+ ::Harness.timing "action_subscriber.ack_duration.#{event_name}", event.duration
11
+ end
12
+
13
+ ::ActiveSupport::Notifications.subscribe "message_nacked.action_subscriber" do |*args|
14
+ event = ::ActiveSupport::Notifications::Event.new(*args)
15
+ event_name = event.payload[:queue].gsub(".", "-")
16
+ ::Harness.increment "action_subscriber.messages_nacked.#{event_name}"
17
+ ::Harness.timing "action_subscriber.nack_duration.#{event_name}", event.duration
18
+ end
19
+
20
+ ::ActiveSupport::Notifications.subscribe "message_rejected.action_subscriber" do |*args|
21
+ event = ::ActiveSupport::Notifications::Event.new(*args)
22
+ event_name = event.payload[:queue].gsub(".", "-")
23
+ ::Harness.increment "action_subscriber.messages_rejected.#{event_name}"
24
+ ::Harness.timing "action_subscriber.reject_duration.#{event_name}", event.duration
25
+ end
26
+
3
27
  ::ActiveSupport::Notifications.subscribe "popped_event.action_subscriber" do |*args|
4
28
  event = ::ActiveSupport::Notifications::Event.new(*args)
5
29
  event_name = event.payload[:queue].gsub '.', '-'
@@ -1,5 +1,5 @@
1
1
  module Harness
2
2
  module ActionSubscriber
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -0,0 +1,78 @@
1
+ require "spec_helper"
2
+
3
+ describe ::Harness::ActionSubscriber do
4
+ let(:collector) { ::Harness::NullCollector.new }
5
+ let(:queue) { "abacus.amigo.user.created" }
6
+
7
+ before do
8
+ ::Harness.config.queue = ::Harness::SyncQueue.new
9
+ ::Harness.config.collector = collector
10
+ end
11
+
12
+ it "has a version number" do
13
+ expect(Harness::ActionSubscriber::VERSION).not_to be nil
14
+ end
15
+
16
+ describe "message_acked.action_subscriber" do
17
+ it "increments the message_acked counter" do
18
+ expect(collector).to receive(:increment).with("action_subscriber.messages_acked.abacus-amigo-user-created")
19
+ ::ActiveSupport::Notifications.instrument("message_acked.action_subscriber", :queue => queue)
20
+ end
21
+
22
+ it "records the ack_duration" do
23
+ stat = ""
24
+ duration = 0
25
+ expect(collector).to receive(:timing) do |the_stat, the_duration|
26
+ stat = the_stat
27
+ duration = the_duration
28
+ end
29
+ ::ActiveSupport::Notifications.instrument("message_acked.action_subscriber", :queue => queue) do
30
+ sleep 0.1
31
+ end
32
+ expect(stat).to eq("action_subscriber.ack_duration.abacus-amigo-user-created")
33
+ expect(duration).to be >= 0.1
34
+ end
35
+ end
36
+
37
+ describe "message_nacked.action_subscriber" do
38
+ it "increments the message_nacked counter" do
39
+ expect(collector).to receive(:increment).with("action_subscriber.messages_nacked.abacus-amigo-user-created")
40
+ ::ActiveSupport::Notifications.instrument("message_nacked.action_subscriber", :queue => queue)
41
+ end
42
+
43
+ it "records the nack_duration" do
44
+ stat = ""
45
+ duration = 0
46
+ expect(collector).to receive(:timing) do |the_stat, the_duration|
47
+ stat = the_stat
48
+ duration = the_duration
49
+ end
50
+ ::ActiveSupport::Notifications.instrument("message_nacked.action_subscriber", :queue => queue) do
51
+ sleep 0.1
52
+ end
53
+ expect(stat).to eq("action_subscriber.nack_duration.abacus-amigo-user-created")
54
+ expect(duration).to be >= 0.1
55
+ end
56
+ end
57
+
58
+ describe "message_rejected.action_subscriber" do
59
+ it "increments the message_rejected counter" do
60
+ expect(collector).to receive(:increment).with("action_subscriber.messages_rejected.abacus-amigo-user-created")
61
+ ::ActiveSupport::Notifications.instrument("message_rejected.action_subscriber", :queue => queue)
62
+ end
63
+
64
+ it "records the reject_duration" do
65
+ stat = ""
66
+ duration = 0
67
+ expect(collector).to receive(:timing) do |the_stat, the_duration|
68
+ stat = the_stat
69
+ duration = the_duration
70
+ end
71
+ ::ActiveSupport::Notifications.instrument("message_rejected.action_subscriber", :queue => queue) do
72
+ sleep 0.1
73
+ end
74
+ expect(stat).to eq("action_subscriber.reject_duration.abacus-amigo-user-created")
75
+ expect(duration).to be >= 0.1
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,11 @@
1
+ require "bundler/setup"
2
+ require "harness/action_subscriber"
3
+
4
+ RSpec.configure do |config|
5
+ # Enable flags like --only-failures and --next-failure
6
+ config.example_status_persistence_file_path = ".rspec_status"
7
+
8
+ config.expect_with :rspec do |c|
9
+ c.syntax = :expect
10
+ end
11
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: harness-action_subscriber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - mmmries
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-05 00:00:00.000000000 Z
11
+ date: 2018-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,34 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: activesupport
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '3.2'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '3.2'
41
69
  - !ruby/object:Gem::Dependency
42
70
  name: harness
43
71
  requirement: !ruby/object:Gem::Requirement
@@ -81,6 +109,8 @@ files:
81
109
  - harness-action_subscriber.gemspec
82
110
  - lib/harness/action_subscriber.rb
83
111
  - lib/harness/action_subscriber/version.rb
112
+ - spec/harness/action_subscriber_spec.rb
113
+ - spec/spec_helper.rb
84
114
  homepage: https://github.com/mxenabled/harness-action_subscriber
85
115
  licenses:
86
116
  - MIT
@@ -101,8 +131,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
131
  version: '0'
102
132
  requirements: []
103
133
  rubyforge_project:
104
- rubygems_version: 2.5.1
134
+ rubygems_version: 2.7.6
105
135
  signing_key:
106
136
  specification_version: 4
107
137
  summary: Record statsd metrics about ActionSubscriber via Harness
108
- test_files: []
138
+ test_files:
139
+ - spec/harness/action_subscriber_spec.rb
140
+ - spec/spec_helper.rb