rdkafka 0.1.6 → 0.1.7

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: 012eee76eb22d31abf2a33a9c4be70d2f027e53d
4
- data.tar.gz: 63e1947ccc3b9561afada8f722e1fe72806e08a8
3
+ metadata.gz: 05e07e0a842a9c43a3f146ab17b7c9a6a5199695
4
+ data.tar.gz: aaf3de6b32ee405e4b3154931fa8faa997c1f6ab
5
5
  SHA512:
6
- metadata.gz: 0bfbc784de4c85b2308e823a2811cb635ebdf0f63b336748f2631f97c124f5ac2e4cfad5483e4d88abdcbe420b5eeece2cbd0e62202716bc8b892c38f3ae60ca
7
- data.tar.gz: cd5f6f1b84ff2b9aad1210ae3394dd60c0d96a077176e205815e75d267052221acc17682a8db565bc20aea0ca06de742bb347ce1bea3d3de92846db2d907c785
6
+ metadata.gz: 99c48f6357f58933fbe4d7473b6331b3b02e7e902d24edf3d7361e6c12ce647d9c6055c1882c7eb4a481dab713680f0b09bd3922c5a265c9e032c36dda80cd8f
7
+ data.tar.gz: d62fbdb64afb51f3027f7764b29ddc3c7857fe5c771a4c49bc799cfacaf67b662de568e20ee3f3706068062f712e6aed2b3ac58e0f1e009357fb67c7ae965a9d
data/ext/Rakefile CHANGED
@@ -18,7 +18,7 @@ task :default => :clean do
18
18
  end
19
19
  lib_path = File.join(File.dirname(__FILE__), "ports/#{recipe.host}/librdkafka/#{Rdkafka::LIBRDKAFKA_VERSION}/lib/librdkafka.#{from_extension}")
20
20
  FileUtils.mv(lib_path, File.join(File.dirname(__FILE__), "librdkafka.#{to_extension}"))
21
- # Cleanup files created miniportile we don't need in the gem
21
+ # Cleanup files created by miniportile we don't need in the gem
22
22
  FileUtils.rm_rf File.join(File.dirname(__FILE__), "tmp")
23
23
  FileUtils.rm_rf File.join(File.dirname(__FILE__), "ports")
24
24
  end
data/lib/rdkafka/ffi.rb CHANGED
@@ -35,6 +35,10 @@ module Rdkafka
35
35
  self[:err]
36
36
  end
37
37
 
38
+ def topic
39
+ FFI.rd_kafka_topic_name(self[:rkt])
40
+ end
41
+
38
42
  def partition
39
43
  self[:partition]
40
44
  end
@@ -60,7 +64,7 @@ module Rdkafka
60
64
  end
61
65
 
62
66
  def to_s
63
- "Message with key '#{key}', payload '#{payload}', partition '#{partition}', offset '#{offset}'"
67
+ "Message in '#{topic}' with key '#{key}', payload '#{payload}', partition '#{partition}', offset '#{offset}'"
64
68
  end
65
69
 
66
70
  def self.release(ptr)
@@ -69,6 +73,7 @@ module Rdkafka
69
73
  end
70
74
 
71
75
  attach_function :rd_kafka_message_destroy, [:pointer], :void
76
+ attach_function :rd_kafka_topic_name, [:pointer], :string
72
77
 
73
78
  # TopicPartition ad TopicPartitionList structs
74
79
 
@@ -62,6 +62,8 @@ module Rdkafka
62
62
  end
63
63
  end
64
64
 
65
+ class WaitTimeoutError < RuntimeError; end
66
+
65
67
  class DeliveryHandle < ::FFI::Struct
66
68
  layout :pending, :bool,
67
69
  :response, :int,
@@ -73,10 +75,18 @@ module Rdkafka
73
75
  end
74
76
 
75
77
  # Wait for the delivery report
76
- def wait
78
+ def wait(timeout_in_seconds=10)
79
+ timeout = if timeout_in_seconds
80
+ Time.now.to_i + timeout_in_seconds
81
+ else
82
+ nil
83
+ end
77
84
  loop do
78
85
  if pending?
79
- sleep 0.05
86
+ if timeout && timeout <= Time.now.to_i
87
+ raise WaitTimeoutError.new("Waiting for delivery timed out after #{timeout_in_seconds} seconds")
88
+ end
89
+ sleep 0.1
80
90
  next
81
91
  elsif self[:response] != 0
82
92
  raise RdkafkaError.new(self[:response])
@@ -1,4 +1,4 @@
1
1
  module Rdkafka
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  LIBRDKAFKA_VERSION = "0.11.0"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdkafka
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thijs Cadier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-30 00:00:00.000000000 Z
11
+ date: 2017-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi