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 +4 -4
- data/README.md +7 -1
- data/lib/rafka/producer.rb +9 -2
- data/lib/rafka/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6433420dd9138afcf06ba4251fbec9648d198009
|
4
|
+
data.tar.gz: '09b46d94e65a9b2d9dbe06c6f2d0e3371fe80d8c'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
|
data/lib/rafka/producer.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
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.
|
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-
|
11
|
+
date: 2017-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|