fluent-plugin-wendelin 0.1 → 0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6e6c384d1f285c3556d5386d79ef196abdee347f
4
- data.tar.gz: e59ea08e8bf2b24d501ac66df7164b8daddc0795
3
+ metadata.gz: e50ee5d5b3aa16a13dbb53978a7b32ea1c6f57f9
4
+ data.tar.gz: 1785d3a126e15bf2e0c2955cdbf1a45009c0f927
5
5
  SHA512:
6
- metadata.gz: 0be6d7dac13b092bbcfad5c41f7719b3137313621a7ba15bf0677573fee89ae398af544774e595a2bbaff7f894bd8030fef4c27389a881f3668a88cec81a9095
7
- data.tar.gz: 0ef2c3b94b5e98c9a7e5ba5a2a4e726b19fa2bf710a6d1034ea4d2b19997041b94d61e6f6b5af4c34c930e8dbccd9cf0c3ad7f25d8dea4ba4de7f4c921e6e53e
6
+ metadata.gz: 0b343fb750f715be40e1ff73524a9d390f058695aae267f3aa5ea6ee8c8e1beae5b31c2b8e9df4df3965047e53c6043e28df127fef74500f532084fe5fb1e968
7
+ data.tar.gz: d191203f96139e5f3b63825be64baac295d822e026281589f3c7db843d0e736a0e2a32c1fc342a6e2c0dfb6960d6412b1d7a18b3ca0ca1d763ae388df51f9304
@@ -1,12 +1,12 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "fluent-plugin-wendelin"
3
- gem.version = "0.1"
3
+ gem.version = "0.2"
4
4
  gem.authors = ["Kirill Smelkov"]
5
5
  gem.email = ["kirr@nexedi.com"]
6
6
  gem.summary = %q{Fluentd output to Wendelin}
7
7
  gem.description = %q{Fluentd output plugin to forward data to Wendelin system}
8
8
  gem.homepage = "https://lab.nexedi.com/nexedi/fluent-plugin-wendelin"
9
- gem.license = "APLv2"
9
+ gem.license = "Apache-2.0"
10
10
 
11
11
  gem.files = `git ls-files -z`.split("\x0")
12
12
  gem.require_paths = ["lib"]
@@ -47,7 +47,7 @@ module Fluent
47
47
  credentials['user'] = @user
48
48
  credentials['password'] = @password
49
49
  end
50
- @wendelin = WendelinClient.new(@streamtool_uri, credentials)
50
+ @wendelin = WendelinClient.new(@streamtool_uri, credentials, @log)
51
51
  end
52
52
 
53
53
  def start
@@ -19,18 +19,17 @@
19
19
  require 'net/http'
20
20
  require 'openssl'
21
21
 
22
- # show request/response traces or not
23
- $trace = false
24
-
25
22
 
26
23
  # class representing a Wendelin client
27
24
  class WendelinClient
28
25
 
29
26
  # `streamtool_uri` - URI pointing to portal_input_data_stream "mountpoint"
30
27
  # `credentials` # {'user' => _, 'password' => _} TODO change to certificate
31
- def initialize(streamtool_uri, credentials)
28
+ # `log` - logger to use
29
+ def initialize(streamtool_uri, credentials, log)
32
30
  @streamtool_uri = streamtool_uri
33
31
  @credentials = credentials
32
+ @log = log
34
33
  end
35
34
 
36
35
 
@@ -48,15 +47,15 @@ class WendelinClient
48
47
  # req.content_type = 'application/octet-stream'
49
48
  req.set_form_data('data_chunk' => data_chunk)
50
49
 
51
- if $trace
52
- puts '>>> REQUEST'
53
- puts "method\t=> #{req.method}"
54
- puts "path\t=> #{req.path}"
55
- puts "uri\t=> #{req.uri}"
56
- puts "body\t=> #{req.body}"
57
- puts "body_stream\t=> #{req.body_stream}"
58
- req.each {|h| puts "#{h}:\t#{req[h]}"}
59
- puts
50
+ @log.on_trace do
51
+ @log.trace '>>> REQUEST'
52
+ @log.trace "method\t=> #{req.method}"
53
+ @log.trace "path\t=> #{req.path}"
54
+ @log.trace "uri\t=> #{req.uri}"
55
+ @log.trace "body\t=> #{req.body}"
56
+ @log.trace "body_stream\t=> #{req.body_stream}"
57
+ req.each {|h| @log.trace "#{h}:\t#{req[h]}"}
58
+ @log.trace
60
59
  end
61
60
 
62
61
  begin
@@ -66,30 +65,38 @@ class WendelinClient
66
65
  :use_ssl => (uri.scheme == 'https'),
67
66
  # NOTE = "do not check server cert"
68
67
  # TODO move this out to conf parameters
69
- :verify_mode => OpenSSL::SSL::VERIFY_NONE
68
+ :verify_mode => OpenSSL::SSL::VERIFY_NONE,
69
+
70
+ # Net::HTTP default open timeout is infinity, which results
71
+ # in thread hang forever if other side does not fully
72
+ # establish connection. Default read_timeout is 60 seconds.
73
+ # We go safe way and make sure all timeouts are defined.
74
+ :ssl_timeout => 60,
75
+ :open_timeout => 60,
76
+ :read_timeout => 60,
70
77
  ) do |http|
71
78
  http.request(req)
72
79
  end
73
80
 
74
81
  rescue
75
82
  # some http/ssl/other connection error
76
- puts "HTTP ERROR:"
83
+ @log.warn "HTTP ERROR:"
77
84
  raise
78
85
 
79
86
  else
80
- if $trace
81
- puts '>>> RESPONSE'
82
- res.each {|h| puts "#{h}:\t#{res[h]}"}
83
- puts "code\t=> #{res.code}"
84
- puts "msg\t=> #{res.message}"
85
- puts "class\t=> #{res.class}"
86
- puts "body:", res.body
87
+ @log.on_trace do
88
+ @log.trace '>>> RESPONSE'
89
+ res.each {|h| @log.trace "#{h}:\t#{res[h]}"}
90
+ @log.trace "code\t=> #{res.code}"
91
+ @log.trace "msg\t=> #{res.message}"
92
+ @log.trace "class\t=> #{res.class}"
93
+ @log.trace "body:", res.body
87
94
  end
88
95
 
89
96
  if res.kind_of?(Net::HTTPSuccess) # res.code is 2XX
90
- #puts "ingested ok"
97
+ #@log.info "ingested ok"
91
98
  else
92
- puts "FAIL:"
99
+ @log.warn "FAIL:"
93
100
  res.value
94
101
  end
95
102
  end
@@ -5,6 +5,10 @@
5
5
  here = File.dirname(__FILE__)
6
6
  $LOAD_PATH << File.expand_path(File.join(here, '../lib'))
7
7
  require 'fluent/plugin/wendelin_client'
8
+ require 'fluent/log'
9
+ require 'fluent/engine' # for log
10
+
11
+ log = Fluent::Log.new(out=STDERR, level=Fluent::Log::LEVEL_TRACE)
8
12
 
9
13
  # FIXME hardcoded
10
14
  $user = 'user'
@@ -14,7 +18,7 @@ $password = 'password'
14
18
  $erp5 = "https://example.com/erp5" # erp5 root
15
19
  $streamtool = "#{$erp5}/portal_input_data_streams" # where Input Stream Tool is mounted
16
20
 
17
- $wendelin = WendelinClient.new($streamtool, {'user' => $user, 'password' => $password})
21
+ $wendelin = WendelinClient.new($streamtool, {'user' => $user, 'password' => $password}, log)
18
22
 
19
23
 
20
24
  def ingest(input_stream_ref, data_chunk)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-wendelin
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: '0.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kirill Smelkov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-25 00:00:00.000000000 Z
11
+ date: 2016-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -44,7 +44,7 @@ files:
44
44
  - test/wendelin_test.rb
45
45
  homepage: https://lab.nexedi.com/nexedi/fluent-plugin-wendelin
46
46
  licenses:
47
- - APLv2
47
+ - Apache-2.0
48
48
  metadata: {}
49
49
  post_install_message:
50
50
  rdoc_options: []
@@ -62,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
62
62
  version: '0'
63
63
  requirements: []
64
64
  rubyforge_project:
65
- rubygems_version: 2.2.2
65
+ rubygems_version: 2.5.1
66
66
  signing_key:
67
67
  specification_version: 4
68
68
  summary: Fluentd output to Wendelin