delivery_boy 1.0.1 → 1.1.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: 13839750d8addd8784d886e3b8a4056cbc74af2656ff5424a63ba8a4ca6f4a86
4
- data.tar.gz: 931c327dc9db84ba9526518b6a3a59f467ffa1268d0569197e6b242d19f89ef3
3
+ metadata.gz: a12782da215edcc91544e184fd5804b2c21fb4a4be180f69addd0e2f7787884e
4
+ data.tar.gz: 6de9279ba3441524aceef6091a4feaf57d67a8623499779877b39ed9a11edad9
5
5
  SHA512:
6
- metadata.gz: b5bb98ab0ff079b8bdfccfa8217f59bdef0bad956602485da3339edcf155553ce25ded599bd78b58a8715b693ec3d4bda06bb48ed81e7c8073b3a28d398e0a29
7
- data.tar.gz: cfecd1aa7996a29db2520abc8a5240ea23d423a4bc1458a52c7190170605ce39e2ba778c75b03127e2a692463cd8f06130a415b1f4c8a047c989ace2d43f8bfb
6
+ metadata.gz: 6787bea888f6a2db4bb0d66eaad3c2234c9b6e4482c81ec69e43c27960b4c4a191ec553c0a24c87a46c5067811e2b9eb85265b34fc9457692465dfa8d902c5af
7
+ data.tar.gz: e10d3020dbaedfe5608fab51e6e1d343341919aab23b905766cdc386e2b844d5177d464fba93d69b79cc6d3704a5ad703ca97464f5754a363a9d362fecec2559
data/CHANGELOG CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## Unreleased
4
+
5
+ ## v1.1.0
6
+
7
+ * Support for `ssl_client_cert_key_password` in the configuration (#52)
8
+ * Add `DeliveryBoy.buffer_size` to return the number of messages in the buffer
9
+ * Add `DeliveryBoy::Fake#clear_buffer` and `DeliveryBoy::Fake#buffer_size` to
10
+ support the public API when using the test helper.
11
+ * Support for `sasl_oauth_token_provider` in the configuration. (#55)
12
+
3
13
  ## v1.0.1
4
14
 
5
15
  * Require ruby-kafka v1.0 or higher.
data/README.md CHANGED
@@ -66,7 +66,7 @@ A third method is to produce messages first (without delivering the messages to
66
66
  class CommentsController < ApplicationController
67
67
  def create
68
68
  @comment = Comment.create!(params)
69
-
69
+
70
70
  event = {
71
71
  name: "comment_created",
72
72
  data: {
@@ -74,13 +74,13 @@ A third method is to produce messages first (without delivering the messages to
74
74
  user_id: current_user.id
75
75
  }
76
76
  }
77
-
77
+
78
78
  # This will queue the two messages in the internal buffer.
79
79
  DeliveryBoy.produce(comment.to_json, topic: "comments")
80
80
  DeliveryBoy.produce(event.to_json, topic: "activity")
81
-
81
+
82
82
  # This will deliver all messages in the buffer to Kafka.
83
- # This call is blocking.
83
+ # This call is blocking.
84
84
  DeliveryBoy.deliver_messages
85
85
  end
86
86
  end
@@ -220,11 +220,15 @@ A PEM encoded client cert to use with an SSL connection. Must be used in combina
220
220
 
221
221
  A PEM encoded client cert key to use with an SSL connection. Must be used in combination with `ssl_client_cert`.
222
222
 
223
+ ##### `ssl_client_cert_key_password`
224
+
225
+ The password required to read the ssl_client_cert_key. Must be used in combination with ssl_client_cert_key.
226
+
223
227
  #### SASL Authentication and authorization
224
228
 
225
229
  See [ruby-kafka](https://github.com/zendesk/ruby-kafka#authentication-using-sasl) for more information.
226
230
 
227
- Use either `sasl_gssapi_*` _or_ `sasl_plain_*`, not both.
231
+ Use it through `GSSAPI`, `PLAIN` _or_ `OAUTHBEARER`.
228
232
 
229
233
  ##### `sasl_gssapi_principal`
230
234
 
@@ -246,6 +250,25 @@ The username used to authenticate.
246
250
 
247
251
  The password used to authenticate.
248
252
 
253
+ ##### `sasl_oauth_token_provider`
254
+
255
+ A instance of a class which implements the `token` method.
256
+ As described in [ruby-kafka](https://github.com/zendesk/ruby-kafka/tree/c3e90bc355fad1e27b9af1048966ff08d3d5735b#oauthbearer)
257
+
258
+ ```ruby
259
+ class TokenProvider
260
+ def token
261
+ "oauth-token"
262
+ end
263
+ end
264
+
265
+ DeliveryBoy.configure do |config|
266
+ config.sasl_oauth_token_provider = TokenProvider.new
267
+ config.ssl_ca_certs_from_system = true
268
+ end
269
+ ```
270
+
271
+
249
272
  ### Testing
250
273
 
251
274
  DeliveryBoy provides a test mode out of the box. When this mode is enabled, messages will be stored in memory rather than being sent to Kafka. If you use RSpec, enabling test mode is as easy as adding this to your spec helper:
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.require_paths = ["lib"]
22
22
 
23
23
  spec.add_runtime_dependency "ruby-kafka", "~> 1.0"
24
- spec.add_runtime_dependency "king_konf", "~> 0.3"
24
+ spec.add_runtime_dependency "king_konf", "~> 1.0"
25
25
 
26
26
  spec.add_development_dependency "bundler", "~> 1.15"
27
27
  spec.add_development_dependency "rake", "~> 10.0"
@@ -4,6 +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/config_error"
7
8
  require "delivery_boy/railtie" if defined?(Rails::Railtie)
8
9
 
9
10
  module DeliveryBoy
@@ -85,6 +86,11 @@ module DeliveryBoy
85
86
  instance.clear_buffer
86
87
  end
87
88
 
89
+ # Return the number of messages in the buffer
90
+ def buffer_size
91
+ instance.buffer_size
92
+ end
93
+
88
94
  # Shut down DeliveryBoy.
89
95
  #
90
96
  # Automatically called when the process exits.
@@ -38,6 +38,7 @@ module DeliveryBoy
38
38
  string :ssl_ca_cert_file_path
39
39
  string :ssl_client_cert, default: nil
40
40
  string :ssl_client_cert_key, default: nil
41
+ string :ssl_client_cert_key_password, default: nil
41
42
  boolean :ssl_ca_certs_from_system, default: false
42
43
  boolean :ssl_verify_hostname, default: true
43
44
 
@@ -52,6 +53,9 @@ module DeliveryBoy
52
53
  string :sasl_scram_mechanism
53
54
  boolean :sasl_over_ssl, default: true
54
55
 
56
+ # SASL OAUTHBEARER
57
+ attr_accessor :sasl_oauth_token_provider
58
+
55
59
  # Datadog monitoring
56
60
  boolean :datadog_enabled
57
61
  string :datadog_host
@@ -51,6 +51,18 @@ module DeliveryBoy
51
51
  clear
52
52
  end
53
53
 
54
+ def clear_buffer
55
+ @delivery_lock.synchronize do
56
+ @buffer.clear
57
+ end
58
+ end
59
+
60
+ def buffer_size
61
+ @delivery_lock.synchronize do
62
+ @buffer.values.flatten.size
63
+ end
64
+ end
65
+
54
66
  # Clear all messages stored in memory.
55
67
  def clear
56
68
  @delivery_lock.synchronize do
@@ -40,6 +40,10 @@ module DeliveryBoy
40
40
  sync_producer.clear_buffer
41
41
  end
42
42
 
43
+ def buffer_size
44
+ sync_producer.buffer_size
45
+ end
46
+
43
47
  private
44
48
 
45
49
  attr_reader :config, :logger
@@ -80,6 +84,7 @@ module DeliveryBoy
80
84
  ssl_ca_cert_file_path: config.ssl_ca_cert_file_path,
81
85
  ssl_client_cert: config.ssl_client_cert,
82
86
  ssl_client_cert_key: config.ssl_client_cert_key,
87
+ ssl_client_cert_key_password: config.ssl_client_cert_key_password,
83
88
  ssl_ca_certs_from_system: config.ssl_ca_certs_from_system,
84
89
  ssl_verify_hostname: config.ssl_verify_hostname,
85
90
  sasl_gssapi_principal: config.sasl_gssapi_principal,
@@ -90,7 +95,8 @@ module DeliveryBoy
90
95
  sasl_scram_username: config.sasl_scram_username,
91
96
  sasl_scram_password: config.sasl_scram_password,
92
97
  sasl_scram_mechanism: config.sasl_scram_mechanism,
93
- sasl_over_ssl: config.sasl_over_ssl
98
+ sasl_over_ssl: config.sasl_over_ssl,
99
+ sasl_oauth_token_provider: config.sasl_oauth_token_provider
94
100
  )
95
101
  end
96
102
 
@@ -1,3 +1,3 @@
1
1
  module DeliveryBoy
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.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: 1.0.1
4
+ version: 1.1.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: 2020-03-09 00:00:00.000000000 Z
11
+ date: 2021-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-kafka
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.3'
33
+ version: '1.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.3'
40
+ version: '1.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -130,8 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  requirements: []
133
- rubyforge_project:
134
- rubygems_version: 2.7.6
133
+ rubygems_version: 3.1.2
135
134
  signing_key:
136
135
  specification_version: 4
137
136
  summary: A simple way to produce messages to Kafka from Ruby applications