Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fluent-plugin-wendelin
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
fluent-plugin-wendelin
Commits
b918d2ff
Commit
b918d2ff
authored
Jul 08, 2018
by
Eteri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make timeouts configurable
parent
4dc6b905
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
21 deletions
+30
-21
lib/fluent/plugin/out_wendelin.rb
lib/fluent/plugin/out_wendelin.rb
+7
-2
lib/fluent/plugin/wendelin_client.rb
lib/fluent/plugin/wendelin_client.rb
+23
-19
No files found.
lib/fluent/plugin/out_wendelin.rb
View file @
b918d2ff
...
@@ -40,7 +40,10 @@ module Fluent
...
@@ -40,7 +40,10 @@ module Fluent
config_param
:use_keep_alive
,
:bool
,
:default
=>
false
config_param
:use_keep_alive
,
:bool
,
:default
=>
false
config_param
:ssl_timeout
,
:integer
,
:default
=>
60
config_param
:open_timeout
,
:integer
,
:default
=>
60
config_param
:read_timeout
,
:integer
,
:default
=>
60
config_param
:keep_alive_timeout
,
:integer
,
:default
=>
300
def
configure
(
conf
)
def
configure
(
conf
)
super
super
...
@@ -50,7 +53,9 @@ module Fluent
...
@@ -50,7 +53,9 @@ module Fluent
credentials
[
'user'
]
=
@user
credentials
[
'user'
]
=
@user
credentials
[
'password'
]
=
@password
credentials
[
'password'
]
=
@password
end
end
@wendelin
=
WendelinClient
.
new
(
@streamtool_uri
,
credentials
,
@log
)
@wendelin
=
WendelinClient
.
new
(
@streamtool_uri
,
credentials
,
@log
,
@ssl_timeout
,
@open_timeout
,
@read_timeout
,
@keep_alive_timeout
)
end
end
def
start
def
start
...
...
lib/fluent/plugin/wendelin_client.rb
View file @
b918d2ff
...
@@ -24,18 +24,22 @@ class WendelinClient
...
@@ -24,18 +24,22 @@ class WendelinClient
# `streamtool_uri` - URI pointing to portal_input_data_stream "mountpoint"
# `streamtool_uri` - URI pointing to portal_input_data_stream "mountpoint"
# `credentials` # {'user' => _, 'password' => _} TODO change to certificate
# `credentials` # {'user' => _, 'password' => _} TODO change to certificate
# `log` - logger to use
# `log` - logger to use
def
initialize
(
streamtool_uri
,
credentials
,
log
)
def
initialize
(
streamtool_uri
,
credentials
,
log
,
ssl_timeout
,
open_timeout
,
read_timeout
,
keep_alive_timeout
)
@streamtool_uri
=
streamtool_uri
@streamtool_uri
=
streamtool_uri
@credentials
=
credentials
@credentials
=
credentials
@log
=
log
@log
=
log
# @stop_timer = 0
@ssl_timeout
=
ssl_timeout
@open_timeout
=
open_timeout
@read_timeout
=
read_timeout
@keep_alive_timeout
=
keep_alive_timeout
end
end
# start request in an independent function to keep the connection open
# start request in an independent function to keep the connection open
def
start_
request
(
uri
)
def
start_
connection
(
uri
)
puts
" START NEW REQUEST
"
@log
.
debug
"start new connection
"
@http
=
Net
::
HTTP
.
start
(
uri
.
hostname
,
uri
.
port
,
@http
=
Net
::
HTTP
.
start
(
uri
.
hostname
,
uri
.
port
,
:use_ssl
=>
(
uri
.
scheme
==
'https'
),
:use_ssl
=>
(
uri
.
scheme
==
'https'
),
...
@@ -45,23 +49,23 @@ class WendelinClient
...
@@ -45,23 +49,23 @@ class WendelinClient
# in thread hang forever if other side does not fully
# in thread hang forever if other side does not fully
# establish connection. Default read_timeout is 60 seconds.
# establish connection. Default read_timeout is 60 seconds.
# We go safe way and make sure all timeouts are defined.
# We go safe way and make sure all timeouts are defined.
:ssl_timeout
=>
60
,
:ssl_timeout
=>
@ssl_timeout
,
:open_timeout
=>
60
,
:open_timeout
=>
@open_timeout
,
:read_timeout
=>
60
,
:read_timeout
=>
@read_timeout
,
:keep_alive_timeout
=>
60
,)
:keep_alive_timeout
=>
@keep_alive_timeout
,)
end
end
# ingest `data_chunk` to a stream referenced as `reference`
# ingest `data_chunk` to a stream referenced as `reference`
def
ingest_with_keep_alive
(
reference
,
data_chunk
)
def
ingest_with_keep_alive
(
reference
,
data_chunk
)
uri
=
URI
(
"
#{
@streamtool_uri
}
/ingest?reference=
#{
reference
}
"
)
uri
=
URI
(
"
#{
@streamtool_uri
}
/ingest?reference=
#{
reference
}
"
)
puts
"uri = "
# call start_connection if http is undefined
puts
uri
if
!
defined?
@http
# call start_request if request is undefined
start_connection
(
uri
)
@request
||=
start_request
(
uri
)
end
# connect again if the connection is not started
# connect again if the connection is not started
if
!
@http
.
started?
()
if
!
@http
.
started?
()
start_
request
(
uri
)
start_
connection
(
uri
)
end
end
@request
=
Net
::
HTTP
::
Post
.
new
(
uri
)
@request
=
Net
::
HTTP
::
Post
.
new
(
uri
)
...
@@ -150,9 +154,9 @@ class WendelinClient
...
@@ -150,9 +154,9 @@ class WendelinClient
# in thread hang forever if other side does not fully
# in thread hang forever if other side does not fully
# establish connection. Default read_timeout is 60 seconds.
# establish connection. Default read_timeout is 60 seconds.
# We go safe way and make sure all timeouts are defined.
# We go safe way and make sure all timeouts are defined.
:ssl_timeout
=>
60
,
:ssl_timeout
=>
@ssl_timeout
,
:open_timeout
=>
60
,
:open_timeout
=>
@open_timeout
,
:read_timeout
=>
60
,
:read_timeout
=>
@read_timeout
,
)
do
|
http
|
)
do
|
http
|
http
.
request
(
req
)
http
.
request
(
req
)
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment