delivery_boy 0.2.8 → 1.0.0

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
  SHA256:
3
- metadata.gz: 7d1d10c8e6cf173eeca342252bf3e47327f08200fd6e34207e803d6ef490ead7
4
- data.tar.gz: 4e7d841926323cc46aefec6cdf93812796ae2a454a562e4ad0c6d02eb79b229e
3
+ metadata.gz: 9c12a635fd3f30ba232c8c6780325ac5e156235b0664f48285a5b368b1853aed
4
+ data.tar.gz: 27e94f5691510f02999cc666474e165833fd3e42800f50728c7e4c3ed57d0e1d
5
5
  SHA512:
6
- metadata.gz: 6388bf8cadefd13a20ceabb7e887171e0f6c8dc42cb5f31a5370da7578bb5e5913192a20161d0370af43cc3a88798f74417886657f887e636fec2586dddfd27a
7
- data.tar.gz: e1cbea934e040fcea51b9730e0340376aef0f59ede9c8d82199bba3b0adc60c309ef87a86ade3b7a6bb1d9f7136403dfb6d64408693974f4832f85a04ce24500
6
+ metadata.gz: a5aa32a2e97e37b1ce80578cf569717c584f3aff81ee8933b1dad033d6e1aba2b12893b99d7d1d875fec02161605c263efd807221cbf5b37e306bd9e94c61535
7
+ data.tar.gz: 9299c44e1c0f32e43f9702be7fc2194fcf393a3dc77a6d08271d7bc2ec76436e8c9bd9e65f3165d1db42ff2d4b9c0036827f0b05d3b283cb90ca697bdcff5e49
data/CHANGELOG CHANGED
@@ -1,6 +1,10 @@
1
1
  # Changelog
2
2
 
3
- ## Unreleased
3
+ ## v1.0.0
4
+
5
+ * Add `DeliveryBoy.clear_buffer` method.
6
+ * Support exactly once delivery and transactional messaging (#50)
7
+ * Check that Rails::Railtie is defined (#48)
4
8
 
5
9
  ## v0.2.8
6
10
 
@@ -4,7 +4,7 @@ require "delivery_boy/version"
4
4
  require "delivery_boy/instance"
5
5
  require "delivery_boy/fake"
6
6
  require "delivery_boy/config"
7
- require "delivery_boy/railtie" if defined?(Rails)
7
+ require "delivery_boy/railtie" if defined?(Rails::Railtie)
8
8
 
9
9
  module DeliveryBoy
10
10
  class << self
@@ -80,6 +80,11 @@ module DeliveryBoy
80
80
  instance.deliver_messages
81
81
  end
82
82
 
83
+ # Clear any buffered messages generated by {.produce} or {.produce!} methods.
84
+ def clear_buffer
85
+ instance.clear_buffer
86
+ end
87
+
83
88
  # Shut down DeliveryBoy.
84
89
  #
85
90
  # Automatically called when the process exits.
@@ -25,6 +25,9 @@ module DeliveryBoy
25
25
  integer :max_retries, default: 2
26
26
  integer :required_acks, default: -1
27
27
  integer :retry_backoff, default: 1
28
+ boolean :idempotent, default: false
29
+ boolean :transactional, default: false
30
+ integer :transactional_timeout, default: 60
28
31
 
29
32
  # Compression
30
33
  integer :compression_threshold, default: 1
@@ -2,7 +2,7 @@ module DeliveryBoy
2
2
 
3
3
  # A fake implementation that is useful for testing.
4
4
  class Fake
5
- FakeMessage = Struct.new(:value, :topic, :key, :offset, :partition, :partition_key, :create_time) do
5
+ FakeMessage = Struct.new(:value, :topic, :key, :headers, :offset, :partition, :partition_key, :create_time) do
6
6
  def bytesize
7
7
  key.to_s.bytesize + value.to_s.bytesize
8
8
  end
@@ -14,10 +14,10 @@ module DeliveryBoy
14
14
  @delivery_lock = Mutex.new
15
15
  end
16
16
 
17
- def deliver(value, topic:, key: nil, partition: nil, partition_key: nil, create_time: Time.now)
17
+ def deliver(value, topic:, key: nil, headers: {}, partition: nil, partition_key: nil, create_time: Time.now)
18
18
  @delivery_lock.synchronize do
19
19
  offset = @messages[topic].count
20
- message = FakeMessage.new(value, topic, key, offset, partition, partition_key, create_time)
20
+ message = FakeMessage.new(value, topic, key, headers, offset, partition, partition_key, create_time)
21
21
 
22
22
  @messages[topic] << message
23
23
  end
@@ -27,10 +27,10 @@ module DeliveryBoy
27
27
 
28
28
  alias deliver_async! deliver
29
29
 
30
- def produce(value, topic:, key: nil, partition: nil, partition_key: nil, create_time: Time.now)
30
+ def produce(value, topic:, key: nil, headers: {}, partition: nil, partition_key: nil, create_time: Time.now)
31
31
  @delivery_lock.synchronize do
32
32
  offset = @buffer[topic].count
33
- message = FakeMessage.new(value, topic, key, offset, partition, partition_key, create_time)
33
+ message = FakeMessage.new(value, topic, key, headers, offset, partition, partition_key, create_time)
34
34
 
35
35
  @buffer[topic] << message
36
36
  end
@@ -14,7 +14,7 @@ module DeliveryBoy
14
14
  sync_producer.deliver_messages
15
15
  rescue
16
16
  # Make sure to clear any buffered messages if there's an error.
17
- sync_producer.clear_buffer
17
+ clear_buffer
18
18
 
19
19
  raise
20
20
  end
@@ -36,6 +36,10 @@ module DeliveryBoy
36
36
  sync_producer.deliver_messages
37
37
  end
38
38
 
39
+ def clear_buffer
40
+ sync_producer.clear_buffer
41
+ end
42
+
39
43
  private
40
44
 
41
45
  attr_reader :config, :logger
@@ -101,6 +105,9 @@ module DeliveryBoy
101
105
  max_buffer_bytesize: config.max_buffer_bytesize,
102
106
  compression_codec: (config.compression_codec.to_sym if config.compression_codec),
103
107
  compression_threshold: config.compression_threshold,
108
+ idempotent: config.idempotent,
109
+ transactional: config.transactional,
110
+ transactional_timeout: config.transactional_timeout,
104
111
  }
105
112
  end
106
113
  end
@@ -1,3 +1,3 @@
1
1
  module DeliveryBoy
2
- VERSION = "0.2.8"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: delivery_boy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Schierbeck
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-31 00:00:00.000000000 Z
11
+ date: 2019-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-kafka
@@ -130,7 +130,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  requirements: []
133
- rubygems_version: 3.0.3
133
+ rubyforge_project:
134
+ rubygems_version: 2.7.6
134
135
  signing_key:
135
136
  specification_version: 4
136
137
  summary: A simple way to produce messages to Kafka from Ruby applications