waterdrop 1.0.0 → 1.0.1

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: a9078e08b7d8417a1a7a25dec1a720d8e4c695e2
4
- data.tar.gz: f0cb1d1745665a2cc2281f289ebf5c7672fa9b77
3
+ metadata.gz: 4c194065166002b613a559ba2818edc33edea127
4
+ data.tar.gz: ca654d85779ccefd488269360a977db8e3406f54
5
5
  SHA512:
6
- metadata.gz: eb25c8240e32e82ef5c8621900c46ba91aea522e5b1e3c0e743d070b8ebfece12020cff2e5e53ceebb2a49dfb23096940b95fef5cd0f09d3f19f938477ea43a8
7
- data.tar.gz: a76dfe91b91a00bb23b0d7abed94a86f077d5aacce7346e49cae7b2c6b99d0d37cdedb1938a453a97cf06a3fe23735cfd40430b5289800277d1b8590887c7b66
6
+ metadata.gz: dee9f25037979516a0f5d62591e4cce4706a2f54b10862e63bc0ea757664f6dc7b442efb501f70e9eafe0b1ec9d6389be0f9b74968369faeefa69ad1adf864d4
7
+ data.tar.gz: da09ca5c22c4553e0c6f82fb16a7761bf97453c8f6ac8a3713ac350f09ffe69f47150912a48f4c2574b9bdacc6197d9ad445dff2ee4c030a082035e5c8ef33b1
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # WaterDrop changelog
2
2
 
3
+ ## 1.0.1
4
+ - Added high level retry on connection problems
5
+
3
6
  ## 1.0.0
4
7
 
5
8
  - #37 - ack level for producer
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- waterdrop (1.0.0.alpha2)
4
+ waterdrop (1.0.1)
5
5
  delivery_boy (>= 0.2.2)
6
6
  dry-configurable (~> 0.7)
7
7
  dry-validation (~> 0.11)
@@ -22,14 +22,14 @@ GEM
22
22
  dry-container (0.6.0)
23
23
  concurrent-ruby (~> 1.0)
24
24
  dry-configurable (~> 0.1, >= 0.1.3)
25
- dry-core (0.4.0)
25
+ dry-core (0.4.1)
26
26
  concurrent-ruby (~> 1.0)
27
27
  dry-equalizer (0.2.0)
28
28
  dry-logic (0.4.2)
29
29
  dry-container (~> 0.2, >= 0.2.6)
30
30
  dry-core (~> 0.2)
31
31
  dry-equalizer (~> 0.2)
32
- dry-types (0.12.1)
32
+ dry-types (0.12.2)
33
33
  concurrent-ruby (~> 1.0)
34
34
  dry-configurable (~> 0.1)
35
35
  dry-container (~> 0.3)
data/README.md CHANGED
@@ -89,9 +89,7 @@ To send Kafka messages, just use one of the producers:
89
89
 
90
90
  ```ruby
91
91
  WaterDrop::SyncProducer.call('message', topic: 'my-topic')
92
-
93
92
  # or for async
94
-
95
93
  WaterDrop::AsyncProducer.call('message', topic: 'my-topic')
96
94
  ```
97
95
 
@@ -99,7 +97,7 @@ Both ```SyncProducer``` and ```AsyncProducer``` accept following options:
99
97
 
100
98
  | Option | Required | Value type | Description |
101
99
  |-------------------- |----------|----------------|---------------------------------------------------------------------|
102
- | ```topic``` | true | String, Symbol | The Kafka topic that should be written to |
100
+ | ```topic``` | true | String | The Kafka topic that should be written to |
103
101
  | ```key``` | false | String | The key that should be set on the Kafka message |
104
102
  | ```partition``` | false | Integer | A specific partition number that should be written to |
105
103
  | ```partition_key``` | false | String | A string that can be used to deterministically select the partition |
@@ -3,6 +3,27 @@
3
3
  # WaterDrop library
4
4
  module WaterDrop
5
5
  # Async producer for messages
6
- AsyncProducer = Class.new(BaseProducer)
7
- AsyncProducer.method_name = :deliver_async
6
+ class AsyncProducer < BaseProducer
7
+ # Performs message delivery using deliver_async method
8
+ # @param message [String] message that we want to send to Kafka
9
+ # @param options [Hash] options (including topic) for producer
10
+ # @raise [WaterDrop::Errors::InvalidMessageOptions] raised when message options are
11
+ # somehow invalid and we cannot perform delivery because of that
12
+ def self.call(message, options)
13
+ attempts ||= 0
14
+ attempts += 1
15
+
16
+ validate!(options)
17
+ return unless WaterDrop.config.deliver
18
+ DeliveryBoy.deliver_async(message, options)
19
+ rescue Kafka::Error => e
20
+ if attempts > WaterDrop.config.kafka.max_retries
21
+ WaterDrop.logger.error e
22
+ raise e
23
+ else
24
+ WaterDrop.logger.warn "Retrying delivery after: #{e}"
25
+ retry
26
+ end
27
+ end
28
+ end
8
29
  end
@@ -5,20 +5,6 @@ module WaterDrop
5
5
  # sync and async producers
6
6
  class BaseProducer
7
7
  class << self
8
- # Delivery boy method name that we use to invoke producer action
9
- attr_accessor :method_name
10
-
11
- # Performs message delivery using method_name method
12
- # @param message [String] message that we want to send to Kafka
13
- # @param options [Hash] options (including topic) for producer
14
- # @raise [WaterDrop::Errors::InvalidMessageOptions] raised when message options are
15
- # somehow invalid and we cannot perform delivery because of that
16
- def call(message, options)
17
- validate!(options)
18
- return unless WaterDrop.config.deliver
19
- DeliveryBoy.public_send(method_name, message, options)
20
- end
21
-
22
8
  private
23
9
 
24
10
  # Runs the message options validations and raises an error if anything is invalid
@@ -3,6 +3,27 @@
3
3
  # WaterDrop library
4
4
  module WaterDrop
5
5
  # Sync producer for messages
6
- SyncProducer = Class.new(BaseProducer)
7
- SyncProducer.method_name = :deliver
6
+ class SyncProducer < BaseProducer
7
+ # Performs message delivery using deliver_async method
8
+ # @param message [String] message that we want to send to Kafka
9
+ # @param options [Hash] options (including topic) for producer
10
+ # @raise [WaterDrop::Errors::InvalidMessageOptions] raised when message options are
11
+ # somehow invalid and we cannot perform delivery because of that
12
+ def self.call(message, options)
13
+ attempts ||= 0
14
+ attempts += 1
15
+
16
+ validate!(options)
17
+ return unless WaterDrop.config.deliver
18
+ DeliveryBoy.deliver(message, options)
19
+ rescue Kafka::Error => e
20
+ if attempts > WaterDrop.config.kafka.max_retries
21
+ WaterDrop.logger.error e
22
+ raise e
23
+ else
24
+ WaterDrop.logger.warn "Retrying delivery after: #{e}"
25
+ retry
26
+ end
27
+ end
28
+ end
8
29
  end
@@ -3,5 +3,5 @@
3
3
  # WaterDrop library
4
4
  module WaterDrop
5
5
  # Current WaterDrop version
6
- VERSION = '1.0.0'
6
+ VERSION = '1.0.1'
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: waterdrop
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maciej Mensfeld
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-03 00:00:00.000000000 Z
11
+ date: 2017-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: delivery_boy