Class: LogStash::Inputs::HTTP_Poller
- Inherits:
-
Base
- Object
- Base
- LogStash::Inputs::HTTP_Poller
- Extended by:
- PluginMixins::ValidatorSupport::FieldReferenceValidationAdapter
- Includes:
- PluginMixins::ECSCompatibilitySupport::TargetCheck, PluginMixins::EventSupport::EventFactoryAdapter, PluginMixins::Scheduler
- Defined in:
- lib/logstash/inputs/http_poller.rb
Instance Method Summary collapse
- #close ⇒ Object
- #register ⇒ Object
- #run(queue) ⇒ Object
- #run_once(queue) ⇒ Object
- #setup_schedule(queue) ⇒ Object
- #stop ⇒ Object
Instance Method Details
#close ⇒ Object
63 64 65 |
# File 'lib/logstash/inputs/http_poller.rb', line 63 def close close_client end |
#register ⇒ Object
50 51 52 53 54 55 |
# File 'lib/logstash/inputs/http_poller.rb', line 50 def register @host = Socket.gethostname.force_encoding(Encoding::UTF_8) setup_ecs_field! setup_requests! end |
#run(queue) ⇒ Object
174 175 176 |
# File 'lib/logstash/inputs/http_poller.rb', line 174 def run(queue) setup_schedule(queue) end |
#run_once(queue) ⇒ Object
192 193 194 195 196 197 198 199 200 201 |
# File 'lib/logstash/inputs/http_poller.rb', line 192 def run_once(queue) @requests.each do |name, request| # prevent executing a scheduler kick after the plugin has been stop-ed # this could easily happen as the scheduler shutdown is not immediate return if stop? request_async(queue, name, request) end client.execute! unless stop? end |
#setup_schedule(queue) ⇒ Object
178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/logstash/inputs/http_poller.rb', line 178 def setup_schedule(queue) #schedule hash must contain exactly one of the allowed keys msg_invalid_schedule = "Invalid config. schedule hash must contain " + "exactly one of the following keys - cron, at, every or in" raise Logstash::ConfigurationError, msg_invalid_schedule if @schedule.keys.length != 1 schedule_type = @schedule.keys.first schedule_value = @schedule[schedule_type] raise LogStash::ConfigurationError, msg_invalid_schedule unless %w(cron every at in).include?(schedule_type) opts = schedule_type == "every" ? { first_in: 0.01 } : {} scheduler.public_send(schedule_type, schedule_value, opts) { run_once(queue) } scheduler.join end |
#stop ⇒ Object
58 59 60 |
# File 'lib/logstash/inputs/http_poller.rb', line 58 def stop close_client end |