rafka 0.0.9 → 0.0.10

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: 6433420dd9138afcf06ba4251fbec9648d198009
4
- data.tar.gz: '09b46d94e65a9b2d9dbe06c6f2d0e3371fe80d8c'
3
+ metadata.gz: bd382881554109f44a7d73b49b26ae278d95edd1
4
+ data.tar.gz: a4557ecc43452232812c65e9b3c1174a6bae61e2
5
5
  SHA512:
6
- metadata.gz: d1536a5c8d50bb5c65dc4dceb1f95041992a73480ca6723f02a4b971042887f10043a4bc713f1e38c787c87e182cc87924d316c95ec8de1e3efebc2267e9f775
7
- data.tar.gz: ecb53962cbe84ea9b8f039498a1ee22afee1e2eac62bc1ea2fefc18be7e1595e2901d5328a4e307434d88d44887581ff4fc059620db77115748d31beeda5706c
6
+ metadata.gz: 55f3f0fe3241ce4ce6006f23c3dbe62ad596b9b7e7cab14425ee796384b7e53be9ef9068e4a163ca6284999bfc6263ac73af5bdce45aafe67310b34677b9b0b6
7
+ data.tar.gz: bae37cb4f878b7a5be3a6feb99fd35a9e97b017ec4755091acda2b7e85b4d1359139e26d7be30ead961cab2c03adb853e2452046e773da105cc1a8fd3d2d7f71
data/README.md CHANGED
@@ -3,19 +3,12 @@ rafka-rb: Ruby driver for Rafka
3
3
  [![Gem Version](https://badge.fury.io/rb/rafka.svg)](https://badge.fury.io/rb/rafka-rb)
4
4
  [![Documentation](http://img.shields.io/badge/yard-docs-blue.svg)](http://www.rubydoc.info/github/skroutz/rafka-rb)
5
5
 
6
- Rafka is a thin Ruby client library for [Rafka](https://github.com/skroutz/rafka),
6
+ rafka-rb is a thin Ruby client library for [Rafka](https://github.com/skroutz/rafka),
7
7
  providing a consumer and a producer with simple semantics. It is backed by
8
8
  [redis-rb](https://github.com/redis/redis-rb).
9
9
 
10
10
  View the [API documentation](http://www.rubydoc.info/github/skroutz/rafka-rb).
11
11
 
12
- Status
13
- -------------------------------------------------------------------------------
14
-
15
- Rafka is not yet stable and therefore is _not_ recommended for production use.
16
-
17
-
18
-
19
12
 
20
13
 
21
14
 
@@ -41,7 +34,6 @@ and run `bundle install`.
41
34
 
42
35
 
43
36
 
44
-
45
37
  Usage
46
38
  -------------------------------------------------------------------------------
47
39
 
@@ -25,15 +25,20 @@ module Rafka
25
25
  @topic = "topics:#{opts[:topic]}"
26
26
  end
27
27
 
28
- # Fetch the next message.
28
+ # Fetches the next message. Offsets are commited automatically. In the
29
+ # block form, the offset is commited only if the given block haven't
30
+ # raised any exceptions.
29
31
  #
30
32
  # @param timeout [Fixnum] the time in seconds to wait for a message
31
33
  #
32
34
  # @raise [MalformedMessageError] if the message cannot be parsed
33
35
  #
34
- # @return [nil, Message] the message, if any
36
+ # @return [nil, Message]
35
37
  #
36
- # @example
38
+ # @example Consume a message
39
+ # puts consume(5).value
40
+ #
41
+ # @example Consume and commit offset if the block runs successfully
37
42
  # consume(5) { |msg| puts "I received #{msg.value}" }
38
43
  def consume(timeout=5)
39
44
  # redis-rb didn't automatically call `CLIENT SETNAME` until v3.2.2
data/lib/rafka/message.rb CHANGED
@@ -8,10 +8,16 @@ module Rafka
8
8
  raise MalformedMessageError.new(msg)
9
9
  end
10
10
 
11
- @topic = msg[1]
12
- @partition = msg[3]
13
- @offset = msg[5]
14
- @value = msg[7]
11
+ @topic = msg[1]
12
+
13
+ begin
14
+ @partition = Integer(msg[3])
15
+ @offset = Integer(msg[5])
16
+ rescue ArgumentError
17
+ raise MalformedMessageError.new(msg)
18
+ end
19
+
20
+ @value = msg[7]
15
21
  end
16
22
  end
17
23
  end
@@ -49,7 +49,7 @@ module Rafka
49
49
  # @return [Fixnum] The number of unflushed messages
50
50
  def flush(timeout_ms=5000)
51
51
  Rafka.wrap_errors do
52
- @redis.dump(timeout_ms.to_s)
52
+ Integer(@redis.dump(timeout_ms.to_s))
53
53
  end
54
54
  end
55
55
 
data/lib/rafka/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rafka
2
- VERSION = "0.0.9".freeze
2
+ VERSION = "0.0.10".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rafka
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Agis Anastasopoulos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-26 00:00:00.000000000 Z
11
+ date: 2018-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis