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 +4 -4
- data/CHANGELOG +5 -1
- data/lib/delivery_boy.rb +6 -1
- data/lib/delivery_boy/config.rb +3 -0
- data/lib/delivery_boy/fake.rb +5 -5
- data/lib/delivery_boy/instance.rb +8 -1
- data/lib/delivery_boy/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c12a635fd3f30ba232c8c6780325ac5e156235b0664f48285a5b368b1853aed
|
4
|
+
data.tar.gz: 27e94f5691510f02999cc666474e165833fd3e42800f50728c7e4c3ed57d0e1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5aa32a2e97e37b1ce80578cf569717c584f3aff81ee8933b1dad033d6e1aba2b12893b99d7d1d875fec02161605c263efd807221cbf5b37e306bd9e94c61535
|
7
|
+
data.tar.gz: 9299c44e1c0f32e43f9702be7fc2194fcf393a3dc77a6d08271d7bc2ec76436e8c9bd9e65f3165d1db42ff2d4b9c0036827f0b05d3b283cb90ca697bdcff5e49
|
data/CHANGELOG
CHANGED
data/lib/delivery_boy.rb
CHANGED
@@ -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.
|
data/lib/delivery_boy/config.rb
CHANGED
@@ -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
|
data/lib/delivery_boy/fake.rb
CHANGED
@@ -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
|
-
|
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
|
data/lib/delivery_boy/version.rb
CHANGED
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.
|
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-
|
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
|
-
|
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
|