logstash-input-http_poller 5.3.1 → 5.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/logstash/inputs/http_poller.rb +11 -15
- data/logstash-input-http_poller.gemspec +2 -2
- data/spec/inputs/http_poller_spec.rb +0 -9
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 959498284e07e414f7be7e02b9df125372526da763a4d273b55fc609186b777c
|
4
|
+
data.tar.gz: 6a6f4dc0da77770581920f719e9de03f3d81bdc079a61fdb43874e5c09d3afa8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3af6dc69528053dcc66ccdef55fbd9dfc56bede4cd383ccd44689a884f601b14b630f1d3accc7d56e86ca41f4bbe544379e7dc8cc23d8794db8b2c6d9fd4711
|
7
|
+
data.tar.gz: 693a73cc6a442b7b78d15987ea99d84a6a3b5a6143b12261a95eda1a7bfec070650771f66c2a652709470e4c5cebdc5e8f0921c6e3265c3942d168d8bb32aea2
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
## 5.4.0
|
2
|
+
- Refactor: start using scheduler mixin [#134](https://github.com/logstash-plugins/logstash-input-http_poller/pull/134)
|
3
|
+
|
1
4
|
## 5.3.1
|
2
5
|
- Fix: make sure plugin is closing the http client [#130](https://github.com/logstash-plugins/logstash-input-http_poller/pull/130)
|
3
6
|
|
@@ -4,11 +4,11 @@ require "logstash/namespace"
|
|
4
4
|
require "logstash/plugin_mixins/http_client"
|
5
5
|
require "socket" # for Socket.gethostname
|
6
6
|
require "manticore"
|
7
|
-
require "rufus/scheduler"
|
8
7
|
require "logstash/plugin_mixins/ecs_compatibility_support"
|
9
8
|
require 'logstash/plugin_mixins/ecs_compatibility_support/target_check'
|
10
9
|
require 'logstash/plugin_mixins/validator_support/field_reference_validation_adapter'
|
11
10
|
require 'logstash/plugin_mixins/event_support/event_factory_adapter'
|
11
|
+
require 'logstash/plugin_mixins/scheduler'
|
12
12
|
|
13
13
|
class LogStash::Inputs::HTTP_Poller < LogStash::Inputs::Base
|
14
14
|
include LogStash::PluginMixins::HttpClient
|
@@ -18,6 +18,8 @@ class LogStash::Inputs::HTTP_Poller < LogStash::Inputs::Base
|
|
18
18
|
|
19
19
|
extend LogStash::PluginMixins::ValidatorSupport::FieldReferenceValidationAdapter
|
20
20
|
|
21
|
+
include LogStash::PluginMixins::Scheduler
|
22
|
+
|
21
23
|
config_name "http_poller"
|
22
24
|
|
23
25
|
default :codec, "json"
|
@@ -45,7 +47,6 @@ class LogStash::Inputs::HTTP_Poller < LogStash::Inputs::Base
|
|
45
47
|
config :metadata_target, :validate => :string, :default => '@metadata'
|
46
48
|
|
47
49
|
public
|
48
|
-
Schedule_types = %w(cron every at in)
|
49
50
|
def register
|
50
51
|
@host = Socket.gethostname.force_encoding(Encoding::UTF_8)
|
51
52
|
|
@@ -55,15 +56,15 @@ class LogStash::Inputs::HTTP_Poller < LogStash::Inputs::Base
|
|
55
56
|
|
56
57
|
# @overload
|
57
58
|
def stop
|
58
|
-
|
59
|
+
close_client
|
59
60
|
end
|
60
61
|
|
61
62
|
# @overload
|
62
63
|
def close
|
63
|
-
|
64
|
+
close_client
|
64
65
|
end
|
65
66
|
|
66
|
-
def
|
67
|
+
def close_client
|
67
68
|
@logger.debug("closing http client", client: client)
|
68
69
|
begin
|
69
70
|
client.close # since Manticore 0.9.0 this shuts-down/closes all resources
|
@@ -72,12 +73,8 @@ class LogStash::Inputs::HTTP_Poller < LogStash::Inputs::Base
|
|
72
73
|
details[:backtrace] = e.backtrace if @logger.debug?
|
73
74
|
@logger.warn "failed closing http client", details
|
74
75
|
end
|
75
|
-
if @scheduler
|
76
|
-
@logger.debug("shutting down scheduler", scheduler: @scheduler)
|
77
|
-
@scheduler.shutdown(opt) # on newer Rufus (3.8) this joins on the scheduler thread
|
78
|
-
end
|
79
76
|
end
|
80
|
-
private :
|
77
|
+
private :close_client
|
81
78
|
|
82
79
|
private
|
83
80
|
def setup_requests!
|
@@ -185,12 +182,11 @@ class LogStash::Inputs::HTTP_Poller < LogStash::Inputs::Base
|
|
185
182
|
raise Logstash::ConfigurationError, msg_invalid_schedule if @schedule.keys.length != 1
|
186
183
|
schedule_type = @schedule.keys.first
|
187
184
|
schedule_value = @schedule[schedule_type]
|
188
|
-
raise LogStash::ConfigurationError, msg_invalid_schedule unless
|
185
|
+
raise LogStash::ConfigurationError, msg_invalid_schedule unless %w(cron every at in).include?(schedule_type)
|
189
186
|
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
@scheduler.thread.join # due newer rufus (3.8) doing a blocking operation on scheduler.join
|
187
|
+
opts = schedule_type == "every" ? { first_in: 0.01 } : {}
|
188
|
+
scheduler.public_send(schedule_type, schedule_value, opts) { run_once(queue) }
|
189
|
+
scheduler.join
|
194
190
|
end
|
195
191
|
|
196
192
|
def run_once(queue)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-input-http_poller'
|
3
|
-
s.version = '5.
|
3
|
+
s.version = '5.4.0'
|
4
4
|
s.licenses = ['Apache License (2.0)']
|
5
5
|
s.summary = "Decodes the output of an HTTP API into events"
|
6
6
|
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
|
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"
|
22
22
|
s.add_runtime_dependency 'logstash-codec-plain'
|
23
23
|
s.add_runtime_dependency "logstash-mixin-http_client", ">= 7.2.0"
|
24
|
-
s.add_runtime_dependency '
|
24
|
+
s.add_runtime_dependency 'logstash-mixin-scheduler', '~> 1.0'
|
25
25
|
s.add_runtime_dependency 'logstash-mixin-ecs_compatibility_support', '~>1.3'
|
26
26
|
s.add_runtime_dependency 'logstash-mixin-event_support', '~> 1.0', '>= 1.0.1'
|
27
27
|
s.add_runtime_dependency 'logstash-mixin-validator_support', '~> 1.0'
|
@@ -7,15 +7,6 @@ require "timecop"
|
|
7
7
|
require 'rspec/matchers/built_in/raise_error.rb'
|
8
8
|
require 'logstash/plugin_mixins/ecs_compatibility_support/spec_helper'
|
9
9
|
|
10
|
-
begin
|
11
|
-
# TODO: CI work-around - will most likely be moved to the scheduler mixin
|
12
|
-
require 'et-orbi.rb' # a dependency of rufus-scheduler since 3.4
|
13
|
-
::EtOrbi::EoTime.now # might take a long time to initialize - loading time zone
|
14
|
-
# data (from tz-info) and thus gets un-predictable on CI, since the scheduler worker
|
15
|
-
# thread might be stuck starting while we attempt to shutdown in a given time frame
|
16
|
-
rescue LoadError
|
17
|
-
end
|
18
|
-
|
19
10
|
describe LogStash::Inputs::HTTP_Poller do
|
20
11
|
let(:metadata_target) { "_http_poller_metadata" }
|
21
12
|
let(:queue) { Queue.new }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-input-http_poller
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
@@ -62,17 +62,17 @@ dependencies:
|
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
|
-
- - "
|
65
|
+
- - "~>"
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version:
|
68
|
-
name:
|
67
|
+
version: '1.0'
|
68
|
+
name: logstash-mixin-scheduler
|
69
69
|
prerelease: false
|
70
70
|
type: :runtime
|
71
71
|
version_requirements: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: '1.0'
|
76
76
|
- !ruby/object:Gem::Dependency
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|