smith 0.6.5.1 → 0.6.5.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 15e19b548b13abaa3401c8f90ac764f02d55d0e3
4
- data.tar.gz: dd521bbdd079d43906581c451eabc27b6734d0a2
3
+ metadata.gz: 28e4e29c427b83d0923d75bdf2789e01dfec90ff
4
+ data.tar.gz: ec4ecc625c7c52fc8079d9eb9e97bb5c56af40fb
5
5
  SHA512:
6
- metadata.gz: 08947494f7f7c93c667a47b3649d9745fc92105441838950f3ca614becd7dfe53696ecc4623d573c93642e30a6005aa765308466727cfe90b299ea6419223454
7
- data.tar.gz: a279693c851d0cbf971a656c967afff5ac65fce1b3657294a947a74df6c3c20aa20bef5aed4624426a3578dd6fffb2f574558a0127d3d0e5b113edc1b4ca8a35
6
+ metadata.gz: a8d70474e776f60812b052223c253790e4e29ef69b48dfda51dc52513bffa3798b2135db4759131ea9174fa10ec70895f9ffbc4b0aa5852ff2c26c0d869183d9
7
+ data.tar.gz: 4658f5f3d511ad13374cf4fc99cddd46a10aaa483f846acfacf5c61aeae5c170ef95002015d85a36d954b0cada657b84c4ab9145bc9d39566c52b81a1eeff592
@@ -28,14 +28,24 @@ module Smith
28
28
  end
29
29
  else
30
30
  on_work = ->(message, iter) do
31
- begin
32
- sender.publish(json_to_payload(message, options[:type])) do
33
- iter.next
31
+
32
+ error_handler = -> (e) do
33
+ if options[:no_fail]
34
+ logger.error { "#{e} #{message.strip}" }
35
+ iter.call
36
+ else
37
+ blk.call(e.message)
34
38
  end
39
+ end
40
+
41
+ sender.on_serialisation_error do |e, _|
42
+ error_handler.call(e)
43
+ end
44
+
45
+ begin
46
+ sender.publish(json_to_payload(message, options[:type]), &iter)
35
47
  rescue MultiJson::DecodeError => e
36
- blk.call("Json error: #{e.message}")
37
- rescue ACL::Error => e
38
- blk.call(e.message)
48
+ error_handler.call(e)
39
49
  end
40
50
  end
41
51
 
@@ -87,6 +97,7 @@ module Smith
87
97
  opt :reply, "set a reply listener.", :short => :r
88
98
  opt :timeout, "timeout when waiting for a reply", :type => :integer, :depends => :reply, :default => Smith.config.smith.timeout
89
99
  opt :dynamic, "send message to a dynamic queue", :type => :boolean, :default => false, :short => :d
100
+ opt :no_fail, "continue to process input data if there is an error", :type => :boolean, :default => false
90
101
 
91
102
  conflicts :reply, :number, :file
92
103
  conflicts :message, :file
@@ -79,6 +79,13 @@ module Smith
79
79
  @timeout = Timeout.new(timeout || Smith.config.smith.timeout, &blk)
80
80
  end
81
81
 
82
+ # Called if there is a problem serialising an ACL.
83
+ # @yield [blk] block to run when there is an error.
84
+ # @yieldparam [Proc] the publish callback.
85
+ def on_serialisation_error(&blk)
86
+ @on_serialisation_error = blk
87
+ end
88
+
82
89
  # Set up a listener that will receive replies from the published
83
90
  # messages. You must publish with intent to reply -- tee he.
84
91
  #
@@ -179,7 +186,15 @@ module Smith
179
186
  type = @acl_type_cache.get_by_type(message.class)
180
187
 
181
188
  @exchange_completion.completion do |exchange|
182
- exchange.publish(message.to_s, opts.merge(:type => type), &blk)
189
+ begin
190
+ exchange.publish(message.to_s, opts.merge(:type => type), &blk)
191
+ rescue Protobuf::SerializationError => e
192
+ if @on_serialisation_error
193
+ @on_serialisation_error.call(e, blk)
194
+ else
195
+ raise ACL::Error.new(e)
196
+ end
197
+ end
183
198
  end
184
199
  end
185
200
 
data/lib/smith/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Smith
2
- VERSION = "0.6.5.1"
2
+ VERSION = "0.6.5.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smith
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.5.1
4
+ version: 0.6.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Heycock
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-07 00:00:00.000000000 Z
11
+ date: 2014-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj
@@ -164,20 +164,6 @@ dependencies:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
166
  version: '3.6'
167
- - !ruby/object:Gem::Dependency
168
- name: gdbm
169
- requirement: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - "~>"
172
- - !ruby/object:Gem::Version
173
- version: '1.2'
174
- type: :runtime
175
- prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - "~>"
179
- - !ruby/object:Gem::Version
180
- version: '1.2'
181
167
  - !ruby/object:Gem::Dependency
182
168
  name: murmurhash3
183
169
  requirement: !ruby/object:Gem::Requirement