beetle 0.4.9 → 0.4.10
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/RELEASE_NOTES.rdoc +5 -0
- data/examples/headers.rb +42 -0
- data/lib/beetle/message.rb +5 -1
- data/lib/beetle/version.rb +1 -1
- data/test/beetle/message_test.rb +16 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd3e0446ff30e58b35ee415444220672dfbd673a
|
4
|
+
data.tar.gz: da9905e43b9228b064c0213905cc4c0a7f8d423b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13d25b8bf7b3b55977d3ac75f5c020186a7fd5b082ebeffaaa83836015ec9b315855f34605a3ed4a5633c058debe5c8a28eec57c45c7b30e17b616c92b3a1d2b
|
7
|
+
data.tar.gz: 751e5d4fc4c19a7db377a99781d406bf4ea4f36c71c38b6a3eb4c18e9f5aa29aab7a9e65d801986672eef5ad15c6c5f6703a69c19ed7caef6f87715e75541b11
|
data/RELEASE_NOTES.rdoc
CHANGED
data/examples/headers.rb
ADDED
@@ -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
|
data/lib/beetle/message.rb
CHANGED
@@ -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 =
|
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
|
|
data/lib/beetle/version.rb
CHANGED
data/test/beetle/message_test.rb
CHANGED
@@ -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.
|
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-
|
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.
|
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
|