tiny_bus 3.0.0 → 3.1.0
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.
- checksums.yaml +4 -4
- data/lib/tiny_bus.rb +11 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b04a4860504e84547cc02b406c9146d47af4e16563b7509fe2cf3152fe5b6747
|
4
|
+
data.tar.gz: 687328b251069cf527b3de27210ce626884e9e751ccc07ef7accba31a86cd2c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42eda75efbcdbcdd006c1dcdfeb098b48b17e6aecf5f7b27b9a630d8f383ad9a01064e77f77a486e01916ca98d71e036c726e2e5568a227dd4b36d2dc8f0f52c
|
7
|
+
data.tar.gz: 7c9cef3cf505db81c954aa8666007d30a89a2b0384e5e385759e8034ee39eb63a9f7f4d3da3981f37b63c657abece8c70d0b5b48152e1b82df7e5269f2da6909
|
data/lib/tiny_bus.rb
CHANGED
@@ -27,6 +27,8 @@ require 'tiny_pipe'
|
|
27
27
|
# TinyBus.new(dead: <a TinyLog for dead messages>) # will log all undeliverable msgs in this file
|
28
28
|
# TinyBus.new(raise_on_dead: true) # strict mode for undeliverable messages, defaults to false
|
29
29
|
class TinyBus
|
30
|
+
ANNOTATION_PREFIX_DEFAULT = '.'
|
31
|
+
|
30
32
|
# log:
|
31
33
|
# if specified, it should be a TinyLog instance
|
32
34
|
# if not specified, it will create a new TinyLog instance for $stdout
|
@@ -46,13 +48,18 @@ class TinyBus
|
|
46
48
|
# kind of a strict mode. if false, then messages with a '.topic' with no
|
47
49
|
# subscribers will go to the dead file. if true, then messages with a
|
48
50
|
# '.topic' with no subscribers will raise an exception.
|
49
|
-
|
51
|
+
# annotation_prefix:
|
52
|
+
# default: '.'
|
53
|
+
# if specified, the annotated message attributes ('.time', '.msg_uuid', and
|
54
|
+
# '.trace') will have the dot ('.') replaced with the specified prefix text
|
55
|
+
def initialize(log: nil, dead: nil, translator: nil, raise_on_dead: false,
|
56
|
+
annotation_prefix: ANNOTATION_PREFIX_DEFAULT)
|
50
57
|
@subs = {}
|
51
58
|
@translator = translator
|
52
59
|
@annotator = TinyPipe.new([
|
53
|
-
->(m){ m['
|
54
|
-
->(m){ m['
|
55
|
-
->(m){ m['
|
60
|
+
->(m){ m[annotation_prefix + 'time'] = (Time.now.to_f * 1000).to_i; m },
|
61
|
+
->(m){ m[annotation_prefix + 'msg_uuid'] = SecureRandom.uuid; m },
|
62
|
+
->(m){ m[annotation_prefix + 'trace'] ||= SecureRandom.uuid; m }
|
56
63
|
])
|
57
64
|
|
58
65
|
@stats = { '.dead' => 0 }
|
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.1.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: 2022-
|
11
|
+
date: 2022-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tiny_log
|