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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b6e1d34d6fcb98e1be197acf85a0bd17d91a0e4e
4
- data.tar.gz: 6e6047fd40b42401815a712d40b9b84c48e6fddb
3
+ metadata.gz: 2ab33b41289659f97c0ab56f2354b00607bc4fb2
4
+ data.tar.gz: 0d70dc7aa2e4063f6620dd5f4d9e712ea1c2d22f
5
5
  SHA512:
6
- metadata.gz: 2d601d6e41e5e6102389b6a39ecb36aa1eea9fbb683959ca77b3f946248990afd7bbc033519407c480070a3645237e97bad8996572d31c5213506ff45358d298
7
- data.tar.gz: 001ea41bc352f5acd2d63399b502c49c1625da3aebd6f267c4e5d0cf8b4ddb0fac3a4e75776721f8ed77e558f6b0e7e1784ede8068adf58e39f546619cfccb92
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.debug("Message: #{@message}")
46
- with_connection do |socket|
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
- loop { flush; sleep 1 }
36
+ Log.info("Start with #{plugin.host}:#{plugin.port}")
37
+ loop { flush_or_exit; sleep 1 }
59
38
  end
@@ -1,3 +1,3 @@
1
1
  module Kurchatov
2
- VERSION = "0.4.6"
2
+ VERSION = "0.4.7"
3
3
  end
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.6
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-01-27 00:00:00.000000000 Z
11
+ date: 2015-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: beefcake