tiny_bus 3.3.0 → 3.4.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 +6 -18
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b6166f18cf5222d5886b6276f55e5e6eba9f74050f69665a93b1f641a0ae9177
4
- data.tar.gz: 96b2ebda14a8820f268d19c1f7e517937fae4c424faf8cb31bcf20a6b87110e3
3
+ metadata.gz: f3331fb500d2860aabc8902f7c9ca22afe2c9edf32225577ac22b41fe496e440
4
+ data.tar.gz: 637184ebeb5d80a614379af73b96b998d3e655844a4ac77f2427d407cc552c09
5
5
  SHA512:
6
- metadata.gz: b95b706827023d4cbd94030a3f5a382d46543422e6ad47f9bfe2196972c0c106b22082a5654b096de708ccdba8d7d48be949c11b59a1a8ec89162eeec2d6e471
7
- data.tar.gz: b7be435794e5fc4aca6f4baa0ab3b7d35ceaebdd573fe1e60bb7ff5757370917a96c3b4b0ea476796ba2f3e46326e2b524e06d64705f890f4f533c761253c5f4
6
+ metadata.gz: 2c49fe21fd0793a80914bc70d9c32c3fcc8e59fad61deae99f65a46ac122e6372e8eea2c2e0bea01afbb1e9cecb35929e6c3fee7b2d7beb8a7e1a0fbf12dfb1b
7
+ data.tar.gz: 732f63a9a8927a30a339a0214aede09ab23e532a7a1f379fd547f0f33cfcc637448433d785ad2c197572370f269fd71de65104bae84f6570b21dd380f4441492
data/lib/tiny_bus.rb CHANGED
@@ -28,10 +28,6 @@ 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
35
31
 
36
32
  # log:
37
33
  # if specified, it should be a TinyLog instance
@@ -56,15 +52,8 @@ class TinyBus
56
52
  # default: '.'
57
53
  # if specified, the annotated message attributes ('.time', '.msg_uuid', and
58
54
  # '.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
65
55
  def initialize(log: nil, dead: nil, translator: nil, raise_on_dead: false,
66
- annotation_prefix: ANNOTATION_PREFIX_DEFAULT,
67
- logging_overrides: LOGGING_LEVELS)
56
+ annotation_prefix: ANNOTATION_PREFIX_DEFAULT)
68
57
  @subs = {}
69
58
  @translator = translator
70
59
 
@@ -84,8 +73,6 @@ class TinyBus
84
73
  @log = log || TinyLog.new($stdout)
85
74
  @dead = dead || TinyLog.new($stderr)
86
75
  @raise_on_dead = raise_on_dead
87
- @sent_level = logging_overrides['sent'] || LOGGING_LEVELS['sent']
88
- @dead_level = logging_overrides['dead'] || LOGGING_LEVELS['dead']
89
76
  end
90
77
 
91
78
  # adds a subscriber to a topic
@@ -110,9 +97,10 @@ class TinyBus
110
97
  #
111
98
  # msg: the incoming message to be distributed
112
99
  # lvl (optional): the logging level
100
+ # default: 'info'
113
101
  #
114
- # NOTE: it modifies the incoming msg object in place in order to avoid
115
- # unnecessary object allocations
102
+ # NOTE: this method modifies the incoming msg object in place in order to
103
+ # avoid unnecessary object allocations
116
104
  #
117
105
  # NOTE: keys that begin with dot (.), such as '.time' are reserved for
118
106
  # TinyBus and show not be altered by outside code, otherwise undefined
@@ -128,13 +116,13 @@ class TinyBus
128
116
  if (subbers&.length || 0) > 0
129
117
  @stats[topic] += 1
130
118
  subbers.each{|s| s.msg(msg) }
131
- @log.send(@sent_level, msg)
119
+ @log.send(lvl, "S #{msg}")
132
120
  else
133
121
  if @raise_on_dead
134
122
  raise TinyBus::DeadMsgError.new("Could not deliver message to topic `#{topic}'")
135
123
  else
136
124
  @stats[@dead_key] += 1
137
- @dead.send(@dead_level, msg)
125
+ @dead.send(lvl, "D #{msg}")
138
126
  end
139
127
  end
140
128
  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.3.0
4
+ version: 3.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Lunt