beetle 0.4.1 → 0.4.2

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: 8bc8a9a807e4dc4700014a8141bc0655a148f640
4
- data.tar.gz: 8edb6370ac5ffce29a3413e92e95b1c77a64f5e0
3
+ metadata.gz: 3f2aa62352bfa22c0bcf8b02160027aed3429cd6
4
+ data.tar.gz: 491a52bbb628b89165e09671e505147d540844bf
5
5
  SHA512:
6
- metadata.gz: 3663209bba33abb84e9f83b202b86887487b913d9d3314f19f872fdebd8366b8da6fbe9906b8638854c7e47f55b95af5c72357f5f9d0d68820c3891a70cc17db
7
- data.tar.gz: 0627f275d36fa6b18abe866405ade5dcffd8bbb4f48df360aacf94c0b0743394feef73432c19efdaa8c92b3e0f7bdb6d124b190f2c7e4ebe2c23727c05666b39
6
+ metadata.gz: 383565b61fe2689ac5767b668710762bda352a8c1c37253e351e7c5d527e97dbd240e5346403881cf3cf428b0b2137eea1fddb4cba15ea6eb3a2afb7f8f04205
7
+ data.tar.gz: 76fd7ccdb3f16680792695778685fca20102575b1c419ffd6e5fa3d4b48917de7abcbf808f109d2cb3fe70a76cd638d18fffd3165aa93fdefd984daec74722c3
@@ -1,5 +1,9 @@
1
1
  = Release Notes
2
2
 
3
+ == Version 0.4.2
4
+ * Fail hard on missing master file
5
+ * Set message timestamp header
6
+
3
7
  == Version 0.4.1
4
8
  * Require newer bunny version (0.7.10) to fix publishing of messages larger than frame_max
5
9
 
@@ -1,9 +1,10 @@
1
1
  require File.expand_path('../../../lib/beetle', __FILE__)
2
2
 
3
- # Allow using Test::Unit for step assertions
4
- # See http://wiki.github.com/aslakhellesoy/cucumber/using-testunit
5
- require 'test/unit/assertions'
6
- World(Test::Unit::Assertions)
3
+ # See https://github.com/cucumber/cucumber/wiki/Using-MiniTest
4
+ require 'minitest/unit'
5
+ World do
6
+ extend MiniTest::Assertions
7
+ end
7
8
 
8
9
  Before do
9
10
  `ruby features/support/system_notification_logger start`
@@ -189,8 +189,6 @@ module Beetle
189
189
  def redis_master_from_master_file
190
190
  set_current_redis_master_from_master_file if redis_master_file_changed?
191
191
  @current_master
192
- rescue Errno::ENOENT
193
- nil
194
192
  end
195
193
 
196
194
  # redis master file changed outside the running process?
@@ -32,6 +32,8 @@ module Beetle
32
32
  attr_reader :header
33
33
  # the uuid of the message
34
34
  attr_reader :uuid
35
+ # unix timestamp when the message was published
36
+ attr_reader :timestamp
35
37
  # message payload
36
38
  attr_reader :data
37
39
  # the message format version of the message
@@ -76,6 +78,7 @@ module Beetle
76
78
  # p header.attributes
77
79
  amqp_headers = header.attributes
78
80
  @uuid = amqp_headers[:message_id]
81
+ @timestamp = amqp_headers[:timestamp]
79
82
  headers = amqp_headers[:headers].symbolize_keys
80
83
  @format_version = headers[:format_version].to_i
81
84
  @flags = headers[:flags].to_i
@@ -92,6 +95,7 @@ module Beetle
92
95
  expires_at = now + (opts[:ttl] || DEFAULT_TTL)
93
96
  opts = opts.slice(*PUBLISHING_KEYS)
94
97
  opts[:message_id] = generate_uuid.to_s
98
+ opts[:timestamp] = now
95
99
  headers = (opts[:headers] ||= {})
96
100
  headers.merge!(
97
101
  :format_version => FORMAT_VERSION.to_s,
@@ -60,7 +60,7 @@ module Beetle
60
60
 
61
61
  def publish_with_redundancy(exchange_name, message_name, data, opts) #:nodoc:
62
62
  if @servers.size < 2
63
- logger.error "Beetle: at least two active servers are required for redundant publishing"
63
+ logger.warn "Beetle: at least two active servers are required for redundant publishing"
64
64
  return publish_with_failover(exchange_name, message_name, data, opts)
65
65
  end
66
66
  published = []
@@ -1,3 +1,3 @@
1
1
  module Beetle
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
@@ -66,9 +66,9 @@ module Beetle
66
66
  2.times { @store.redis }
67
67
  end
68
68
 
69
- test "should return nil if the master file doesn't exist" do
69
+ test "should blow up if the master file doesn't exist" do
70
70
  Beetle.config.redis_server = "/tmp/__i_don_not_exist__.txt"
71
- assert_equal nil, @store.redis_master_from_master_file
71
+ assert_raises(Errno::ENOENT) { @store.redis_master_from_master_file }
72
72
  end
73
73
 
74
74
  private
@@ -16,6 +16,13 @@ module Beetle
16
16
  assert_equal Message::FORMAT_VERSION, m.format_version
17
17
  end
18
18
 
19
+ test "a message should decode the timestamp" do
20
+ Message.stubs(:now).returns(42)
21
+ header = header_with_params()
22
+ m = Message.new("queue", header, 'foo')
23
+ assert_equal 42, m.timestamp
24
+ end
25
+
19
26
  test "a redundantly encoded message should have the redundant flag set on delivery" do
20
27
  header = header_with_params(:redundant => true)
21
28
  m = Message.new("queue", header, 'foo')
@@ -24,14 +31,14 @@ module Beetle
24
31
  end
25
32
 
26
33
  test "encoding a message with a specfied time to live should set an expiration time" do
27
- Message.expects(:now).returns(25)
34
+ Message.stubs(:now).returns(25)
28
35
  header = header_with_params(:ttl => 17)
29
36
  m = Message.new("queue", header, 'foo')
30
37
  assert_equal 42, m.expires_at
31
38
  end
32
39
 
33
40
  test "encoding a message should set the default expiration date if none is provided in the call to encode" do
34
- Message.expects(:now).returns(1)
41
+ Message.stubs(:now).returns(1)
35
42
  header = header_with_params({})
36
43
  m = Message.new("queue", header, 'foo')
37
44
  assert_equal 1 + Message::DEFAULT_TTL, m.expires_at
@@ -62,6 +69,12 @@ module Beetle
62
69
  assert_equal uuid, options[:message_id]
63
70
  end
64
71
 
72
+ test "the publishing options should include the timestamp" do
73
+ Message.stubs(:now).returns(42)
74
+ options = Message.publishing_options
75
+ assert_equal 42, options[:timestamp]
76
+ end
77
+
65
78
  test "the publishing options must only include string values" do
66
79
  options = Message.publishing_options(:redundant => true, :mandatory => true, :bogus => true)
67
80
 
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.1
4
+ version: 0.4.2
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: 2015-07-16 00:00:00.000000000 Z
15
+ date: 2015-08-25 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: uuid4r
@@ -284,7 +284,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
284
284
  version: 1.3.7
285
285
  requirements: []
286
286
  rubyforge_project:
287
- rubygems_version: 2.4.7
287
+ rubygems_version: 2.4.5
288
288
  signing_key:
289
289
  specification_version: 3
290
290
  summary: High Availability AMQP Messaging with Redundant Queues