kafkr 0.10.0 → 0.13.0
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 +4 -4
- data/exe/kafkr-consumer +6 -4
- data/lib/kafkr/consumer.rb +4 -1
- data/lib/kafkr/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 669818b6d1e72c19fe96e0d9c37cd0688d83613c030beb9a603426a173b0c2b8
|
4
|
+
data.tar.gz: 1b79a859b6ba2e38635df3b98c800940673a7b96ff775674eb68c75c6e647658
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d07a005786bbf2391568c8982fe48f06917036c3f9b054fce2b4930fe92b53204f3b3f912fa8421bc522a60be07aee700e7bddfffe2367fb2ad6eceacb3ed399
|
7
|
+
data.tar.gz: ccb59017f9945f40b01e1f6df350f780176e24d9e46196b4a17f8b2dbee94f934f90d1b4af2ae7ed18a7bedd682c993a8d29fcb535423f1d81f813a545edbdb6
|
data/exe/kafkr-consumer
CHANGED
@@ -7,6 +7,7 @@ require "digest"
|
|
7
7
|
# Accepting command line arguments for host and port
|
8
8
|
host = ARGV[0] || "localhost"
|
9
9
|
port = ARGV[1] || 4000
|
10
|
+
timeout = ARGV[2] || 120
|
10
11
|
|
11
12
|
puts "Running on host: #{host} and port: #{port}"
|
12
13
|
|
@@ -33,13 +34,14 @@ def list_registered_handlers
|
|
33
34
|
end
|
34
35
|
end
|
35
36
|
|
36
|
-
def start_consumer(port, host)
|
37
|
-
puts "Starting consumer on port #{port}!"
|
37
|
+
def start_consumer(port, host, timeout)
|
38
|
+
puts "Starting consumer on port #{port}! timeout: #{timeout}"
|
38
39
|
$handlers_changed = false
|
39
40
|
|
40
41
|
Kafkr::Consumer.configure do |config|
|
41
42
|
config.port = port
|
42
43
|
config.host = host
|
44
|
+
config.timeout = timeout
|
43
45
|
end
|
44
46
|
|
45
47
|
unless $handlers_loaded
|
@@ -95,13 +97,13 @@ end
|
|
95
97
|
|
96
98
|
file_checksums = {}
|
97
99
|
monitoring_thread = Thread.new { monitor_handlers(file_checksums) }
|
98
|
-
start_consumer(port, host) # Pass the port here
|
100
|
+
start_consumer(port, host,timeout) # Pass the port here
|
99
101
|
|
100
102
|
begin
|
101
103
|
loop do
|
102
104
|
if $restart_required
|
103
105
|
stop_consumer
|
104
|
-
start_consumer(port, host)
|
106
|
+
start_consumer(port, host,timeout)
|
105
107
|
$restart_required = false
|
106
108
|
end
|
107
109
|
sleep 1
|
data/lib/kafkr/consumer.rb
CHANGED
@@ -18,6 +18,9 @@ module Kafkr
|
|
18
18
|
def configuration
|
19
19
|
FileUtils.mkdir_p "./.kafkr"
|
20
20
|
@configuration ||= OpenStruct.new
|
21
|
+
@configuration.host = ENV.fetch("KAFKR_HOST", "localhost")
|
22
|
+
@configuration.port = ENV.fetch("KAFKR_PORT", 2000)
|
23
|
+
@configuration.timeout = ENV.fetch("KAFKR_CONSUMER_TIMEOUT", 120)
|
21
24
|
@configuration.suggest_handlers = false
|
22
25
|
@configuration
|
23
26
|
end
|
@@ -150,7 +153,7 @@ module Kafkr
|
|
150
153
|
socket = TCPSocket.new(@host, @port)
|
151
154
|
attempt = 0
|
152
155
|
|
153
|
-
Timeout.timeout(
|
156
|
+
Timeout.timeout(Kafkr::Consumer.configuration.timeout) do
|
154
157
|
sync_uid = send_message.call(message)
|
155
158
|
|
156
159
|
loop do
|
data/lib/kafkr/version.rb
CHANGED