rafka 0.0.8 → 0.0.9

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: d22b37dbbd835861eab2d1de45be8194ef0d0378
4
- data.tar.gz: c2356e4e9e1014a6139e151808559b09fe72081b
3
+ metadata.gz: 6433420dd9138afcf06ba4251fbec9648d198009
4
+ data.tar.gz: '09b46d94e65a9b2d9dbe06c6f2d0e3371fe80d8c'
5
5
  SHA512:
6
- metadata.gz: b30363423f40411dc406e1f2b27d730780c4ffacc9bc971b2ba063449fed15e2d7f68bd4b9ceeafd18c61c608c3b2100015d4b71ceee1cf279cdd939fc57f3f4
7
- data.tar.gz: 5b44cf07218a2d7041a49b4328f57111e415f802da9dbcdaad1dccbc5d3ab909482abe323ff113506f0065a166a03cdf3d5af204a1cf0cea92e2c19ddf92abfc
6
+ metadata.gz: d1536a5c8d50bb5c65dc4dceb1f95041992a73480ca6723f02a4b971042887f10043a4bc713f1e38c787c87e182cc87924d316c95ec8de1e3efebc2267e9f775
7
+ data.tar.gz: ecb53962cbe84ea9b8f039498a1ee22afee1e2eac62bc1ea2fefc18be7e1595e2901d5328a4e307434d88d44887581ff4fc059620db77115748d31beeda5706c
data/README.md CHANGED
@@ -51,7 +51,13 @@ Usage
51
51
  require "rafka"
52
52
 
53
53
  prod = Rafka::Producer.new(host: "localhost", port: 6380)
54
- prod.produce("greetings", "Hello there!") # produce to topic "greetings"
54
+
55
+ # Produce to topic "greetings". The message will be assigned to a random partition.
56
+ prod.produce("greetings", "Hello there!")
57
+
58
+ # Produce using a key. Two or more messages with the same key will always be assigned to the same partition.
59
+ prod.produce("greetings", "Hello there!", key: "hi")
60
+ prod.produce("greetings", "Hi there!", key: "hi")
55
61
  ```
56
62
 
57
63
 
@@ -23,13 +23,20 @@ module Rafka
23
23
  #
24
24
  # @param topic [String]
25
25
  # @param msg [#to_s]
26
+ # @param key [#to_s] two or more messages with the same key will always be
27
+ # assigned to the same partition.
26
28
  #
27
29
  # @example
28
30
  # produce("greetings", "Hello there!")
29
- def produce(topic, msg)
31
+ #
32
+ # @example
33
+ # produce("greetings", "Hello there!", key: "hi")
34
+ def produce(topic, msg, key: nil)
30
35
  Rafka.wrap_errors do
31
36
  Rafka.with_retry(times: @options[:reconnect_attempts]) do
32
- @redis.rpushx("topics:#{topic}", msg.to_s)
37
+ redis_key = "topics:#{topic}"
38
+ redis_key << ":#{key}" if key
39
+ @redis.rpushx(redis_key, msg.to_s)
33
40
  end
34
41
  end
35
42
  end
data/lib/rafka/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rafka
2
- VERSION = "0.0.8".freeze
2
+ VERSION = "0.0.9".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.8
4
+ version: 0.0.9
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-07-17 00:00:00.000000000 Z
11
+ date: 2017-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis