beetle 0.4.9 → 0.4.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5c0645f6fec12cedbcb24c47c2461b107e062e4f
4
- data.tar.gz: 5f30af10846f117fe55483ee1cf17e11b9233aae
3
+ metadata.gz: fd3e0446ff30e58b35ee415444220672dfbd673a
4
+ data.tar.gz: da9905e43b9228b064c0213905cc4c0a7f8d423b
5
5
  SHA512:
6
- metadata.gz: ec3a7ff7cd10bd27fa25f86053b4f0d4ed99430491f8a34e9d1e2a980cac70c0b5d585c3786e1c7cfa17ed99931ea9eceedc8dd59f9b32369914f4bf667b6ee3
7
- data.tar.gz: daa67f9a0d863d90f6915089e29d9e60e80c3c3b02f45e4399d2e0047d88fbf9713afecedbb310068b18116990f3f46117c41f1c0b110799256f5ea6baa4877f
6
+ metadata.gz: 13d25b8bf7b3b55977d3ac75f5c020186a7fd5b082ebeffaaa83836015ec9b315855f34605a3ed4a5633c058debe5c8a28eec57c45c7b30e17b616c92b3a1d2b
7
+ data.tar.gz: 751e5d4fc4c19a7db377a99781d406bf4ea4f36c71c38b6a3eb4c18e9f5aa29aab7a9e65d801986672eef5ad15c6c5f6703a69c19ed7caef6f87715e75541b11
@@ -1,5 +1,10 @@
1
1
  = Release Notes
2
2
 
3
+
4
+ == Version 0.4.10
5
+
6
+ * Publisher handles nil and symbols as values in headers correctly
7
+
3
8
  == Version 0.4.9
4
9
 
5
10
  * Allow redis_configuration_client to run in the foreground (useful
@@ -0,0 +1,42 @@
1
+ # headers.rb
2
+ # this example shows using custom headers
3
+ #
4
+ # ! check the examples/README.rdoc for information on starting your redis/rabbit !
5
+ #
6
+ # start it with ruby headers.rb
7
+
8
+ require "rubygems"
9
+ require File.expand_path("../lib/beetle", File.dirname(__FILE__))
10
+
11
+ # set Beetle log level to info, less noisy than debug
12
+ Beetle.config.logger.level = Logger::INFO
13
+
14
+ # setup client
15
+ client = Beetle::Client.new
16
+ client.register_queue(:test)
17
+ client.register_message(:test)
18
+
19
+ # purge the test queue
20
+ client.purge(:test)
21
+
22
+ # empty the dedup store
23
+ client.deduplication_store.flushdb
24
+
25
+ # register our handler to the message, check out the message.rb for more stuff you can get from the message object
26
+ client.register_handler(:test) {|message| puts "got message with headers: #{message.header.attributes[:headers]}"}
27
+
28
+ # publish our message (NOTE: empty message bodies don't work, most likely due to bugs in bunny/amqp)
29
+ puts client.publish(:test, 'bam', :headers => {
30
+ :header1 => "foo",
31
+ :header2 => 42,
32
+ :header3 => 0.1,
33
+ :header4 => :foo, # will be converted to string
34
+ :header5 => nil # will be filtered out
35
+ })
36
+
37
+ # start listening
38
+ # this starts the event machine event loop using EM.run
39
+ # the block passed to listen will be yielded as the last step of the setup process
40
+ client.listen do
41
+ EM.add_timer(0.1) { client.stop_listening }
42
+ end
@@ -96,12 +96,16 @@ module Beetle
96
96
  opts = opts.slice(*PUBLISHING_KEYS)
97
97
  opts[:message_id] = generate_uuid.to_s
98
98
  opts[:timestamp] = now
99
- headers = (opts[:headers] ||= {})
99
+ headers = {}
100
+ headers.merge!(opts[:headers]) if opts[:headers]
101
+ headers.reject! {|k,v| v.nil? }
102
+ headers.each {|k,v| headers[k] = v.to_s if v.is_a?(Symbol) }
100
103
  headers.merge!(
101
104
  :format_version => FORMAT_VERSION.to_s,
102
105
  :flags => flags.to_s,
103
106
  :expires_at => expires_at.to_s
104
107
  )
108
+ opts[:headers] = headers
105
109
  opts
106
110
  end
107
111
 
@@ -1,3 +1,3 @@
1
1
  module Beetle
2
- VERSION = "0.4.9"
2
+ VERSION = "0.4.10"
3
3
  end
@@ -94,6 +94,22 @@ module Beetle
94
94
  assert_equal "SENDER_ID", options[:headers][:sender_id]
95
95
  assert_equal "SENDER_ACTION", options[:headers][:sender_action]
96
96
  end
97
+
98
+ test "the publishing options convert symbol values to strings" do
99
+ options = Message.publishing_options(:headers => { :x => :foo })
100
+ assert_equal "foo", options[:headers][:x]
101
+ end
102
+
103
+ test "the publishing options reject nil headers" do
104
+ options = Message.publishing_options(:headers => { :x => nil })
105
+ assert !options[:headers].has_key?(:x)
106
+ end
107
+
108
+ test "the publishing options don't change the passed in headers" do
109
+ my_opts = {:headers => { :x => nil }}
110
+ Message.publishing_options(my_opts)
111
+ assert my_opts[:headers].has_key?(:x)
112
+ end
97
113
  end
98
114
 
99
115
  class KeyManagementTest < MiniTest::Unit::TestCase
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beetle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.9
4
+ version: 0.4.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Kaes
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2016-07-27 00:00:00.000000000 Z
15
+ date: 2016-08-08 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: uuid4r
@@ -205,6 +205,7 @@ files:
205
205
  - examples/consume_many_messages_and_shutdown_randomly.rb
206
206
  - examples/handler_class.rb
207
207
  - examples/handling_exceptions.rb
208
+ - examples/headers.rb
208
209
  - examples/multiple_exchanges.rb
209
210
  - examples/multiple_queues.rb
210
211
  - examples/nonexistent_server.rb
@@ -287,7 +288,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
287
288
  version: 1.3.7
288
289
  requirements: []
289
290
  rubyforge_project:
290
- rubygems_version: 2.5.1
291
+ rubygems_version: 2.6.4
291
292
  signing_key:
292
293
  specification_version: 3
293
294
  summary: High Availability AMQP Messaging with Redundant Queues