tiny_bus 3.5.0 → 3.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tiny_bus.rb +14 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10175a5f3eb8391e273b860aefdccd67ff469fb603a063fecdeb58858af6066b
|
4
|
+
data.tar.gz: 2b2a8e6babff0734b57f0b91e2d12bd0782133e0291f4a561441969815deed0e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b1a67cd7b2d5a5e9a93f245c4f9f5b14c70edfcb99a0c64d0b145f3b4349865db668846b5cc9399fbf32f6ddf9ea399f245232535c999c4f8a65754ca9545e0
|
7
|
+
data.tar.gz: 0a22452c404f6e61664b2ce84b4b21f8b686537625c8bbb43c38294e2303262bdab72482d92025f88be4e3a23eac1004a39b1c59850303d01aa76c7d656213df
|
data/lib/tiny_bus.rb
CHANGED
@@ -57,6 +57,7 @@ class TinyBus
|
|
57
57
|
@subs = {}
|
58
58
|
@translator = translator
|
59
59
|
|
60
|
+
@total_key = "#{annotation_prefix}total"
|
60
61
|
@dead_key = "#{annotation_prefix}dead"
|
61
62
|
@topic_key = "#{annotation_prefix}topic"
|
62
63
|
@time_key = "#{annotation_prefix}time"
|
@@ -69,9 +70,9 @@ class TinyBus
|
|
69
70
|
->(m){ m[@trace_key] ||= SecureRandom.uuid; m }
|
70
71
|
])
|
71
72
|
|
72
|
-
@stats = {
|
73
|
-
@log = log || TinyLog.new($stdout)
|
74
|
-
@dead = dead || TinyLog.new($stderr)
|
73
|
+
@stats = { @total_key => 0, @dead_key => 0 }
|
74
|
+
@log = log || TinyLog.new(filename: $stdout)
|
75
|
+
@dead = dead || TinyLog.new(filename: $stderr)
|
75
76
|
@raise_on_dead = raise_on_dead
|
76
77
|
end
|
77
78
|
|
@@ -117,6 +118,7 @@ class TinyBus
|
|
117
118
|
|
118
119
|
subbers = @subs[topic]
|
119
120
|
|
121
|
+
@stats[@total_key] += 1
|
120
122
|
if (subbers&.length || 0) > 0
|
121
123
|
@stats[topic] += 1
|
122
124
|
subbers.each{|s| s.msg(msg) }
|
@@ -131,12 +133,20 @@ class TinyBus
|
|
131
133
|
end
|
132
134
|
end
|
133
135
|
|
136
|
+
# returns a #dup of the internal statistics which track the number of
|
137
|
+
# messages sent to each topic, the dead queue, and total messages
|
138
|
+
def stats
|
139
|
+
@stats.dup
|
140
|
+
end
|
141
|
+
|
134
142
|
# helpful for debugging, gives you a count of the number of messages sent to
|
135
143
|
# each topic, including the .dead topic, which is where messages go where
|
136
144
|
# there are no subscribes for a given topic
|
137
145
|
def to_s
|
138
146
|
<<~DEBUG
|
139
|
-
TinyBus stats: #{@
|
147
|
+
TinyBus stats: #{@stats.keys.length > 0 ? "\n " + @stats.keys.sort.map{|t| "#{t.rjust(12)}: #{@stats[t]}" }.join("\n ") : '<NONE>'}
|
148
|
+
Topics & Subscribers:
|
149
|
+
#{@subs.map{|topic, subbers| "#{topic}\n #{subbers.map(&:to_s).join("\n ")}" }.join("\n ") }
|
140
150
|
DEBUG
|
141
151
|
end
|
142
152
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tiny_bus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Lunt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tiny_log
|
@@ -64,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
64
|
- !ruby/object:Gem::Version
|
65
65
|
version: '0'
|
66
66
|
requirements: []
|
67
|
-
rubygems_version: 3.
|
67
|
+
rubygems_version: 3.4.1
|
68
68
|
signing_key:
|
69
69
|
specification_version: 4
|
70
70
|
summary: want to have an in-memory message bus that takes hash-like objects and distributes
|