rservicebus 0.1.38 → 0.1.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/rservicebus/CronManager.rb +1 -1
- data/lib/rservicebus/Host.rb +9 -10
- data/lib/rservicebus/Message/StatisticOutput.rb +10 -0
- data/lib/rservicebus/StateManager.rb +3 -3
- data/lib/rservicebus/StatisticManager.rb +101 -0
- data/lib/rservicebus/helper_functions.rb +1 -1
- data/lib/rservicebus.rb +2 -0
- metadata +14 -12
data/lib/rservicebus/Host.rb
CHANGED
@@ -149,7 +149,7 @@ module RServiceBus
|
|
149
149
|
#Initialise statistics monitor
|
150
150
|
#
|
151
151
|
def configureStatistics
|
152
|
-
@stats =
|
152
|
+
@stats = StatisticManager.new( self )
|
153
153
|
|
154
154
|
return self
|
155
155
|
end
|
@@ -204,20 +204,14 @@ module RServiceBus
|
|
204
204
|
# - Most of this should be queue independant
|
205
205
|
def StartListeningToEndpoints
|
206
206
|
log "Waiting for messages. To exit press CTRL+C"
|
207
|
-
statOutputCountdown = 0
|
207
|
+
# statOutputCountdown = 0
|
208
208
|
messageLoop = true
|
209
209
|
retries = @config.maxRetries
|
210
210
|
|
211
211
|
while messageLoop do
|
212
212
|
#Popping a msg off the queue should not be in the message handler, as it affects retry
|
213
213
|
begin
|
214
|
-
|
215
|
-
log @stats.getForReporting, true
|
216
|
-
# log @handlerManager.getStats, true
|
217
|
-
statOutputCountdown = @config.statOutputCountdown
|
218
|
-
GC.start
|
219
|
-
end
|
220
|
-
statOutputCountdown = statOutputCountdown - 1
|
214
|
+
@stats.tick
|
221
215
|
|
222
216
|
if @circuitBreaker.Broken then
|
223
217
|
sleep 0.5
|
@@ -230,7 +224,12 @@ module RServiceBus
|
|
230
224
|
@msg = YAML::load(body)
|
231
225
|
if @msg.msg.class.name == "RServiceBus::Message_Subscription" then
|
232
226
|
@subscriptionManager.add( @msg.msg.eventName, @msg.returnAddress )
|
233
|
-
|
227
|
+
elsif @msg.msg.class.name == "RServiceBus::Message_StatisticOutputOn" then
|
228
|
+
@stats.output = true
|
229
|
+
elsif @msg.msg.class.name == "RServiceBus::Message_StatisticOutputOff" then
|
230
|
+
@stats.output = false
|
231
|
+
|
232
|
+
|
234
233
|
else
|
235
234
|
self.HandleMessage()
|
236
235
|
if !@config.forwardReceivedMessagesTo.nil? then
|
@@ -21,17 +21,17 @@ module RServiceBus
|
|
21
21
|
|
22
22
|
#Start
|
23
23
|
def Begin
|
24
|
-
@stateStorage.Begin
|
24
|
+
@stateStorage.Begin unless @stateStorage.nil?
|
25
25
|
end
|
26
26
|
|
27
27
|
#Get
|
28
28
|
def Get( handler )
|
29
|
-
return @stateStorage.Get( handler )
|
29
|
+
return @stateStorage.Get( handler ) unless @stateStorage.nil?
|
30
30
|
end
|
31
31
|
|
32
32
|
#Finish
|
33
33
|
def Commit
|
34
|
-
@stateStorage.Commit
|
34
|
+
@stateStorage.Commit unless @stateStorage.nil?
|
35
35
|
end
|
36
36
|
|
37
37
|
|
@@ -0,0 +1,101 @@
|
|
1
|
+
module RServiceBus
|
2
|
+
|
3
|
+
#Used to collect various run time stats for runtime reporting
|
4
|
+
class StatisticManager
|
5
|
+
|
6
|
+
attr_accessor :output
|
7
|
+
|
8
|
+
def initialize( host )
|
9
|
+
@host = host
|
10
|
+
@hash = Hash.new
|
11
|
+
|
12
|
+
@totalProcessed = 0
|
13
|
+
@totalErrored = 0
|
14
|
+
@totalSent = 0
|
15
|
+
@totalPublished = 0
|
16
|
+
@totalReply = 0
|
17
|
+
|
18
|
+
@totalByMessageType = Hash.new
|
19
|
+
|
20
|
+
@output = !RServiceBus.getValue( "VERBOSE", nil ).nil?
|
21
|
+
@maxStatOutputCountdown = RServiceBus.getValue( "STAT_OUTPUT_COUNTDOWN", "1" ).to_i
|
22
|
+
@statOutputCountdown = 0
|
23
|
+
end
|
24
|
+
|
25
|
+
def incTotalProcessed
|
26
|
+
@totalProcessed = @totalProcessed + 1
|
27
|
+
end
|
28
|
+
|
29
|
+
def incTotalErrored
|
30
|
+
@totalErrored = @totalErrored + 1
|
31
|
+
end
|
32
|
+
|
33
|
+
def incTotalSent
|
34
|
+
@totalSent = @totalSent + 1
|
35
|
+
end
|
36
|
+
|
37
|
+
def incTotalPublished
|
38
|
+
@totalPublished = @totalPublished + 1
|
39
|
+
end
|
40
|
+
|
41
|
+
def incTotalReply
|
42
|
+
@totalReply = @totalReply + 1
|
43
|
+
end
|
44
|
+
|
45
|
+
def inc( key )
|
46
|
+
if @hash[key].nil? then
|
47
|
+
@hash[key] = 0
|
48
|
+
end
|
49
|
+
@hash[key] = @hash[key] + 1
|
50
|
+
end
|
51
|
+
|
52
|
+
def incMessageType( className )
|
53
|
+
if @totalByMessageType[className].nil? then
|
54
|
+
@totalByMessageType[className] = 1
|
55
|
+
else
|
56
|
+
@totalByMessageType[className] = @totalByMessageType[className] + 1
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
def getForReporting2
|
62
|
+
if @written == false then
|
63
|
+
@written = true
|
64
|
+
types = Hash.new(0)
|
65
|
+
ObjectSpace.each_object do|obj|
|
66
|
+
types[obj.class]+=1
|
67
|
+
end
|
68
|
+
|
69
|
+
return types
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def getForReporting9
|
74
|
+
string = "T:#{@totalProcessed};E:#{@totalErrored};S:#{@totalSent};P:#{@totalPublished};R:#{@totalReply}"
|
75
|
+
|
76
|
+
# if @hash.length > 0 then
|
77
|
+
# @hash.each do |k,v|
|
78
|
+
# string = "#{string};#{k}:#{v}"
|
79
|
+
# end
|
80
|
+
# end
|
81
|
+
|
82
|
+
return string
|
83
|
+
end
|
84
|
+
|
85
|
+
def report
|
86
|
+
if @output then
|
87
|
+
@host.log( self.getForReporting9 )
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def tick
|
92
|
+
@statOutputCountdown = @statOutputCountdown - 1
|
93
|
+
if @statOutputCountdown <= 0 then
|
94
|
+
self.report
|
95
|
+
@statOutputCountdown = @maxStatOutputCountdown
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
|
101
|
+
end
|
data/lib/rservicebus.rb
CHANGED
@@ -20,10 +20,12 @@ require "rservicebus/Host"
|
|
20
20
|
require "rservicebus/Config"
|
21
21
|
require "rservicebus/EndpointMapping"
|
22
22
|
require "rservicebus/Stats"
|
23
|
+
require "rservicebus/StatisticManager"
|
23
24
|
require "rservicebus/Audit"
|
24
25
|
|
25
26
|
require "rservicebus/Message"
|
26
27
|
require "rservicebus/Message/Subscription"
|
28
|
+
require "rservicebus/Message/StatisticOutput"
|
27
29
|
|
28
30
|
require "rservicebus/UserMessage/WithPayload"
|
29
31
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rservicebus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.39
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-10-
|
12
|
+
date: 2013-10-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: uuidtools
|
16
|
-
requirement: &
|
16
|
+
requirement: &70165036020780 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70165036020780
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: json
|
27
|
-
requirement: &
|
27
|
+
requirement: &70165036020300 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70165036020300
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: beanstalk-client
|
38
|
-
requirement: &
|
38
|
+
requirement: &70165036019860 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70165036019860
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: fluiddb
|
49
|
-
requirement: &
|
49
|
+
requirement: &70165036019420 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70165036019420
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: parse-cron
|
60
|
-
requirement: &
|
60
|
+
requirement: &70165036018900 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70165036018900
|
69
69
|
description: A Ruby interpretation of NServiceBus
|
70
70
|
email: guy@guyirvine.com
|
71
71
|
executables:
|
@@ -108,6 +108,7 @@ files:
|
|
108
108
|
- lib/rservicebus/HandlerManager.rb
|
109
109
|
- lib/rservicebus/helper_functions.rb
|
110
110
|
- lib/rservicebus/Host.rb
|
111
|
+
- lib/rservicebus/Message/StatisticOutput.rb
|
111
112
|
- lib/rservicebus/Message/Subscription.rb
|
112
113
|
- lib/rservicebus/Message.rb
|
113
114
|
- lib/rservicebus/Monitor/CsvDir.rb
|
@@ -123,6 +124,7 @@ files:
|
|
123
124
|
- lib/rservicebus/StateManager.rb
|
124
125
|
- lib/rservicebus/StateStorage/Dir.rb
|
125
126
|
- lib/rservicebus/StateStorage.rb
|
127
|
+
- lib/rservicebus/StatisticManager.rb
|
126
128
|
- lib/rservicebus/Stats.rb
|
127
129
|
- lib/rservicebus/SubscriptionManager.rb
|
128
130
|
- lib/rservicebus/SubscriptionStorage/File.rb
|