kafka_rest_client 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f604a5dc722bd5ab97847866e46f6326774bc4b5
4
- data.tar.gz: 3d0d283bb69fe749ea2beb0c633e8f4119a190e7
3
+ metadata.gz: 9497ee5597ab5815d3ed45ccf8cda2b727b52dcf
4
+ data.tar.gz: d5cae81efa60f85790db320eec4add0bc816dd1d
5
5
  SHA512:
6
- metadata.gz: b1f3a451c16bd800b1c521aea53faf45dfd4610d326f7c7b201daf975e6114e2260046de1bbc424f15a3afbb70c46ee63f5b3dbe167bbb331a07f9a7d876fcad
7
- data.tar.gz: 2806b9c5e14cddc9df9ca8e17225830f54594860651758aeec031946a196abee1e552d1d53e9a64c478f333669c887875b1a0ae414650ff70f2cd28f90e8433a
6
+ metadata.gz: 83020327a759b9911b1ce1bf81a88d08d39743ca43967b7ee39408a45787271f2cb0b10e110efe3104e786577e4b3b0eee567a29570562dfd3e4bae8391a86b6
7
+ data.tar.gz: 8a3aa2ce7671c8ec923e63f99675092ce3340c2fea9a087964b598a95505b9a55b7f612bba5e25d92fdc378ce6da288919e4b0e7a3a2d2ceb93a9151d28a7b1e
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  A Ruby client to interact with [Kafka REST Proxy](http://docs.confluent.io/1.0.1/kafka-rest/docs/index.html)
4
4
 
5
- **Current Version:** 0.1.0
5
+ **Current Version:** 0.2.1
6
6
 
7
7
  **Supported Ruby versions:** 2.0, 2.1, 2.2
8
8
 
@@ -11,37 +11,43 @@ A Ruby client to interact with [Kafka REST Proxy](http://docs.confluent.io/1.0.1
11
11
  Add this line to your application's Gemfile:
12
12
 
13
13
  ```ruby
14
- gem 'kafka_rest_client', git: 'git@github.com:FundingCircle/kafka_rest_client.git', tag: 'v0.1.0'
14
+ gem 'kafka_rest_client', git: 'git@github.com:FundingCircle/kafka_rest_client.git', tag: 'v0.2.1'
15
15
  ```
16
16
 
17
17
  ## Usage
18
+ ### Configuration
18
19
 
19
- ### Producing events
20
20
  ```ruby
21
- require 'kafka_rest_client'
22
-
23
21
  # Configure global settings
22
+ # The client is disabled if kafka_proxy_url and schema_registry_url are not set
24
23
  KafkaRestClient.configure do |config|
25
24
  config.kafka_proxy_url = ENV['KAFKA_PROXY_URL']
26
25
  config.schema_registry_url = ENV['SCHEMA_REGISTRY_URL']
27
26
  config.timeout = 10
28
27
  config.logger = Rails.logger
29
28
  end
29
+ ```
30
+
31
+ ### Producing events
32
+ ```ruby
33
+ require 'kafka_rest_client'
30
34
 
31
35
  producer = KafkaRestClient::AvroProducer.new
32
36
 
33
37
  # Produce a single event using the topic name and payload
34
- # The schema will be fetched from the schema registry based on the topic name
38
+ # The schema_id will be fetched from the schema registry by looking up a schema
39
+ # with the "#{topic}-value" name
35
40
  producer.produce('ice-cream-melted', { temperature: 35, unit: 'celsius' })
36
41
 
37
42
  # Produce multiple events
38
- # The schema will also be fetched from the schema registry based on the topic name
43
+ # The schema_id will be fetched from the schema registry by looking up a schema
44
+ # with the "#{topic}-value" name
39
45
  producer.produce('ice-cream-melted', [{ temperature: 35, unit: 'celsius' }])
40
46
 
41
47
  # Produce an event providing the schema id
42
48
  producer.produce('ice-cream-melted', { temperature: 35, unit: 'celsius' }, value_schema_id: 1)
43
49
 
44
- # Produce an event providing the full schema
50
+ # Produce an event providing the full schema as a JSON string
45
51
  schema = {
46
52
  type: 'record',
47
53
  name: 'IceCreamMelted',
@@ -71,6 +77,8 @@ rescue KafkaRestClient::SchemaNotFoundError => e
71
77
  # Schema has not been registered in the schema registry
72
78
  rescue KafkaRestClient::TopicNotFoundError => e
73
79
  # Topic does not exist in Kafka, create it with confluent tools
80
+ rescue Net::ReadTimeout => e
81
+ # Rescue read timeout errors
74
82
  end
75
83
  ```
76
84
 
@@ -4,9 +4,10 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'kafka_rest_client'
7
- spec.version = '0.2.0'
7
+ spec.version = '0.2.1'
8
8
  spec.authors = ['Funding Circle Engineering']
9
9
  spec.email = ['engineering+kafka_rest_client@fundingcircle.com']
10
+ spec.licenses = ['BSD-3-Clause']
10
11
 
11
12
  spec.summary = 'Ruby client for interacting with Kafka REST Proxy'
12
13
  spec.description = 'Ruby client for interacting with Kafka REST Proxy'
@@ -5,6 +5,10 @@ module KafkaRestClient
5
5
  attr_accessor :kafka_proxy_url, :schema_registry_url, :timeout, :logger
6
6
  class << self
7
7
  attr_accessor :current
8
+
9
+ def current
10
+ @current ||= Configuration.new
11
+ end
8
12
  end
9
13
 
10
14
  def initialize(options = {})
@@ -15,12 +19,12 @@ module KafkaRestClient
15
19
  end
16
20
 
17
21
  def timeout
18
- @timeout ||= 30
22
+ @timeout ||= 30 # seconds
19
23
  end
20
24
 
21
25
  def logger
22
26
  @logger ||= Logger.new(STDOUT).tap do |logger|
23
- # Set level too high so we don't log anything
27
+ # Set level too high so we don't log anything by default
24
28
  logger.level = Logger::FATAL
25
29
  end
26
30
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kafka_rest_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Funding Circle Engineering
@@ -159,7 +159,8 @@ files:
159
159
  - lib/kafka_rest_client/configuration.rb
160
160
  - lib/kafka_rest_client/errors.rb
161
161
  homepage: http://github.com/FundingCircle/kakfa_rest_client
162
- licenses: []
162
+ licenses:
163
+ - BSD-3-Clause
163
164
  metadata: {}
164
165
  post_install_message:
165
166
  rdoc_options: []