delivery_boy 0.1.3 → 0.1.4

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: 0625c454e902fb754978710dae81fa1ae823a06b
4
- data.tar.gz: 8c37651745002d2c847b55d0185d95e3c9514c4a
3
+ metadata.gz: b22537575f9af9b44a9a9f285e74d073b48bec92
4
+ data.tar.gz: 2505ca15d3d2b60a94fb4c88f1a959803d334c44
5
5
  SHA512:
6
- metadata.gz: 0a73aefdb9f2688ca34314c81ef499a42f29996594229f99263cb3acbc584258b93016c1c4d03e3c3839dcc29ccfcd0bc85cef26e22bea2b4e19f01e6c6d7f98
7
- data.tar.gz: 60a3f71a92629f2470ab40f15a097e73f0b6b63437c2cb43fdfc8f4c3eb5a9aa6a56cf987c449eee1231767573595b98aafb43ae4c3ccf142c4ed6d4744d02bf
6
+ metadata.gz: c5c0e279ebcd829f3b0961d10f705fc74d5307a983547c049542d391361daafdb71ef8c1747770e4b946e56d470e88a78d81b811c9995d26380fcf2ffcb5de13
7
+ data.tar.gz: 69ef0053f5a4873a6deaa9d7071502adb6ee677d5c9678d33467c1dd65473a6e76a97cd6427fe8b1e23feda1e83c506543ddb6010930d990f3aa71ca27b02edc
data/README.md CHANGED
@@ -20,7 +20,7 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- Once you've [installed the gem](#installation), and assuming your Kafka broker is running on localhost, you can simply start publishing messages to Kafka:
23
+ Once you've [installed the gem](#installation), and assuming your Kafka broker is running on localhost, you can simply start publishing messages to Kafka directly from your Rails code:
24
24
 
25
25
  ```ruby
26
26
  # app/controllers/comments_controller.rb
data/lib/delivery_boy.rb CHANGED
@@ -6,6 +6,22 @@ require "delivery_boy/railtie" if defined?(Rails)
6
6
 
7
7
  module DeliveryBoy
8
8
  class << self
9
+
10
+ # Write a message to a specified Kafka topic synchronously.
11
+ #
12
+ # Keep in mind that the client will block until the message has been
13
+ # delivered.
14
+ #
15
+ # @param value [String] the message value.
16
+ # @param topic [String] the topic that the message should be written to.
17
+ # @param key [String, nil] the message key.
18
+ # @param partition [Integer, nil] the topic partition that the message should
19
+ # be written to.
20
+ # @param partition_key [String, nil] a key used to deterministically assign
21
+ # a partition to the message.
22
+ # @return [nil]
23
+ # @raise [Kafka::BufferOverflow] if the producer's buffer is full.
24
+ # @raise [Kafka::DeliveryFailed] if delivery failed for some reason.
9
25
  def deliver(value, topic:, **options)
10
26
  sync_producer.produce(value, topic: topic, **options)
11
27
  sync_producer.deliver_messages
@@ -16,27 +32,47 @@ module DeliveryBoy
16
32
  raise
17
33
  end
18
34
 
35
+ # Like {.deliver_async!}, but handles +Kafka::BufferOverflow+ errors
36
+ # by logging them and just going on with normal business.
37
+ #
38
+ # @return [nil]
19
39
  def deliver_async(value, topic:, **options)
20
40
  deliver_async!(value, topic: topic, **options)
21
41
  rescue Kafka::BufferOverflow
22
42
  logger.error "Message for `#{topic}` dropped due to buffer overflow"
23
43
  end
24
44
 
45
+ # Like {.deliver}, but returns immediately.
46
+ #
47
+ # The actual delivery takes place in a background thread.
48
+ #
49
+ # @return [nil]
25
50
  def deliver_async!(value, topic:, **options)
26
51
  async_producer.produce(value, topic: topic, **options)
27
52
  end
28
53
 
54
+ # Shut down DeliveryBoy.
55
+ #
56
+ # Automatically called when the process exits.
57
+ #
58
+ # @return [nil]
29
59
  def shutdown
30
60
  sync_producer.shutdown if sync_producer?
31
61
  async_producer.shutdown if async_producer?
32
62
  end
33
63
 
64
+ # The logger used by DeliveryBoy.
65
+ #
66
+ # @return [Logger]
34
67
  def logger
35
68
  @logger ||= Logger.new($stdout)
36
69
  end
37
70
 
38
71
  attr_writer :logger
39
72
 
73
+ # The configuration used by DeliveryBoy.
74
+ #
75
+ # @return [DeliveryBoy::Config]
40
76
  def config
41
77
  @config ||= DeliveryBoy::Config.new(env: ENV)
42
78
  end
@@ -75,6 +75,7 @@ module DeliveryBoy
75
75
  def load_env(env)
76
76
  loader = EnvConfigLoader.new(env, self)
77
77
 
78
+ loader.string_list :brokers
78
79
  loader.integer :ack_timeout
79
80
  loader.symbol :compression_codec
80
81
  loader.integer :compression_threshold
@@ -1,3 +1,3 @@
1
1
  module DeliveryBoy
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
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.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Schierbeck
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-05 00:00:00.000000000 Z
11
+ date: 2017-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-kafka