kurchatov 0.4.6 → 0.4.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kurchatov/application.rb +4 -0
- data/lib/kurchatov/responders/ndjson_transport.rb +9 -30
- data/lib/kurchatov/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: 2ab33b41289659f97c0ab56f2354b00607bc4fb2
|
4
|
+
data.tar.gz: 0d70dc7aa2e4063f6620dd5f4d9e712ea1c2d22f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8851e6778223f849cc6de3b55e1b62c881b1608699f50adcef48463bad5d336fb80e9635d7f69a9648b8a2e81da730bbeffab193e5382fcc78c4863f518f4611
|
7
|
+
data.tar.gz: dbd8638280ef6935223c796ffc4ab4ce14771129c12455ba46d9df8637dcbabdcc49b01e175b09cf535f1775b07fe80095b07bd640f74a7ca6e6eae5171e4c99
|
@@ -92,6 +92,10 @@ module Kurchatov
|
|
92
92
|
:long => '--http-transport http://server:port/api',
|
93
93
|
:description => 'Set http server for send events'
|
94
94
|
|
95
|
+
option :nsjson_transport,
|
96
|
+
:long => '--nsjson-transport server:port',
|
97
|
+
:description => 'Set line json reciever for send events'
|
98
|
+
|
95
99
|
option :http_responder,
|
96
100
|
:long => '--http 0.0.0.0:55755',
|
97
101
|
:description => 'Set http responder for information'
|
@@ -4,9 +4,6 @@ always_start true
|
|
4
4
|
ignore_errors true
|
5
5
|
|
6
6
|
default[:host], default[:port] = Kurchatov::Config[:nsjson_transport].to_s.split(":")
|
7
|
-
default[:connect_timeout] = 1
|
8
|
-
default[:send_timeout] = 1
|
9
|
-
default[:exit_on_disconnect] = true
|
10
7
|
|
11
8
|
run_if do
|
12
9
|
!!plugin.host
|
@@ -14,46 +11,28 @@ end
|
|
14
11
|
|
15
12
|
helpers do
|
16
13
|
|
17
|
-
def if_error
|
18
|
-
if plugin.exit_on_disconnect
|
19
|
-
Log.error("Socket #{plugin.host}:#{plugin.port} (#{@socket.inspect}) write error, exit..")
|
20
|
-
exit 99
|
21
|
-
end
|
22
|
-
nil
|
23
|
-
end
|
24
|
-
|
25
|
-
def connect
|
26
|
-
Timeout::timeout(plugin.connect_timeout) {
|
27
|
-
@socket ||= (TCPSocket.new(plugin.host, plugin.port) rescue if_error)
|
28
|
-
}
|
29
|
-
end
|
30
|
-
|
31
14
|
def mutex
|
32
15
|
@mutex ||= Mutex.new
|
33
16
|
end
|
34
17
|
|
35
|
-
def with_connection
|
36
|
-
mutex.synchronize do
|
37
|
-
yield(@socket || connect)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
18
|
def flush
|
19
|
+
@tcpsocket ||= TCPSocket.new(plugin.host, plugin.port.to_i)
|
42
20
|
@events_to_send ||= events.to_flush
|
43
21
|
if !@events_to_send.empty?
|
44
22
|
@message = {"events" => @events_to_send}.to_json
|
45
|
-
Log.
|
46
|
-
|
47
|
-
Timeout::timeout(plugin.send_timeout) {
|
48
|
-
socket.puts(@message)
|
49
|
-
} rescue if_error
|
50
|
-
end
|
23
|
+
Log.info("Message: #{@message}")
|
24
|
+
mutex.synchronize { @tcpsocket.puts(@message) }
|
51
25
|
end
|
52
26
|
@events_to_send = nil
|
53
27
|
end
|
54
28
|
|
29
|
+
def flush_or_exit
|
30
|
+
flush rescue (exit 99)
|
31
|
+
end
|
32
|
+
|
55
33
|
end
|
56
34
|
|
57
35
|
run do
|
58
|
-
|
36
|
+
Log.info("Start with #{plugin.host}:#{plugin.port}")
|
37
|
+
loop { flush_or_exit; sleep 1 }
|
59
38
|
end
|
data/lib/kurchatov/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kurchatov
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vasiliev Dmitry
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: beefcake
|