tiny_bus 3.1.1 → 3.2.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tiny_bus.rb +16 -3
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 27b59f1cbc599aa563486a8fb29274e2369b1099dc01523f96b14bc9f3f0d06f
4
- data.tar.gz: e8f3511275ca57d791808e343e9f70e4855cbaea72a1eb119935b09b4acbbb4e
3
+ metadata.gz: e0b4ee66f65bb60557ba29b72f0ade0e840f0db352ac2f1bca0cab5385b97b19
4
+ data.tar.gz: '089bfc105f34f3538844e5756e3623f8db4f835c58501140cc6d6a02521c17dc'
5
5
  SHA512:
6
- metadata.gz: adfd193f7b1c3f55c66f86d5a096d21b0d1d8e5fb04c2c978cf9885cdb8663ca3d2850dfda25c4debb4b93e5407dd601428f76a184a72f7a1210b0abf7a2ce03
7
- data.tar.gz: 34c31596855df2ac266fd839de02b84c1827cc64ec4ecf2d295cf98748364604be1285c9b0efb9278392fadadd23553d5d342cb76f9b67a037c12c51443361c0
6
+ metadata.gz: 58a576c5b7bc7445b263e93b23ba1ba65e6536dfdd38dfe150251401dfc9490776ca6b751ef27c9ed71ce2bea0901d5292b009bed217c7c0a50c3c852f88e748
7
+ data.tar.gz: 45a52d67eecda3efa9d8e72267413fd0d5adaab5b5f3168278e7938e0edd88f9f29b6e18fb5a98d7058c0a456c3898b83a92549cf7df7a012313bc27b1f8b736
data/lib/tiny_bus.rb CHANGED
@@ -28,6 +28,10 @@ require 'tiny_pipe'
28
28
  # TinyBus.new(raise_on_dead: true) # strict mode for undeliverable messages, defaults to false
29
29
  class TinyBus
30
30
  ANNOTATION_PREFIX_DEFAULT = '.'
31
+ LOGGING_LEVELS = {
32
+ 'sent' => 'SENT',
33
+ 'dead' => 'DEAD'
34
+ }.freeze
31
35
 
32
36
  # log:
33
37
  # if specified, it should be a TinyLog instance
@@ -52,8 +56,15 @@ class TinyBus
52
56
  # default: '.'
53
57
  # if specified, the annotated message attributes ('.time', '.msg_uuid', and
54
58
  # '.trace') will have the dot ('.') replaced with the specified prefix text
59
+ # logging_overrides:
60
+ # default: LOGGING_LEVELS
61
+ # allows you to specify a Hash of overrides of the logging levels for
62
+ # 'SENT' and 'DEAD' message delivery; useful if the consuming application
63
+ # wants to use its own logging levels, or you just want the labels changed
64
+ # for some reason
55
65
  def initialize(log: nil, dead: nil, translator: nil, raise_on_dead: false,
56
- annotation_prefix: ANNOTATION_PREFIX_DEFAULT)
66
+ annotation_prefix: ANNOTATION_PREFIX_DEFAULT,
67
+ logging_overrides: LOGGING_LEVELS)
57
68
  @subs = {}
58
69
  @translator = translator
59
70
 
@@ -73,6 +84,8 @@ class TinyBus
73
84
  @log = log || TinyLog.new($stdout)
74
85
  @dead = dead || TinyLog.new($stderr)
75
86
  @raise_on_dead = raise_on_dead
87
+ @sent_level = logging_overrides['sent'] || LOGGING_LEVELS['sent']
88
+ @dead_level = logging_overrides['dead'] || LOGGING_LEVELS['dead']
76
89
  end
77
90
 
78
91
  # adds a subscriber to a topic
@@ -115,13 +128,13 @@ class TinyBus
115
128
  if (subbers&.length || 0) > 0
116
129
  @stats[topic] += 1
117
130
  subbers.each{|s| s.msg(msg) }
118
- @log.sent msg
131
+ @log.send(@sent_level, msg)
119
132
  else
120
133
  if @raise_on_dead
121
134
  raise TinyBus::DeadMsgError.new("Could not deliver message to topic `#{topic}'")
122
135
  else
123
136
  @stats[@dead_key] += 1
124
- @dead.dead msg
137
+ @dead.send(@dead_level, msg)
125
138
  end
126
139
  end
127
140
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tiny_bus
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Lunt