Class: Fluent::Plugin::HttpPullInput
- Inherits:
-
Input
- Object
- Input
- Fluent::Plugin::HttpPullInput
- Defined in:
- lib/fluent/plugin/in_http_pull.rb
Instance Method Summary collapse
- #configure(conf) ⇒ Object
-
#initialize ⇒ HttpPullInput
constructor
A new instance of HttpPullInput.
- #on_timer ⇒ Object
- #shutdown ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize ⇒ HttpPullInput
Returns a new instance of HttpPullInput.
25 26 27 |
# File 'lib/fluent/plugin/in_http_pull.rb', line 25 def initialize super end |
Instance Method Details
#configure(conf) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/fluent/plugin/in_http_pull.rb', line 87 def configure(conf) compat_parameters_convert(conf, :parser) super @parser = parser_create unless @status_only @_request_headers = { "Content-Type" => "application/x-www-form-urlencoded", "User-Agent" => @agent }.merge(@request_headers.map do |section| header = section["header"] value = section["value"] [header.to_sym, value] end.to_h) @http_method = :head if @status_only end |
#on_timer ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/fluent/plugin/in_http_pull.rb', line 111 def on_timer body = nil record = nil begin res = RestClient::Request.execute record, body = get_record(res) rescue StandardError => err record = { "url" => @url, "error" => err. } if err.respond_to? :http_code record["status"] = err.http_code || 0 else record["status"] = 0 end end record_time = Engine.now record = parse(record, body) router.emit(@tag, record_time, record) end |
#shutdown ⇒ Object
133 134 135 |
# File 'lib/fluent/plugin/in_http_pull.rb', line 133 def shutdown super end |
#start ⇒ Object
105 106 107 108 109 |
# File 'lib/fluent/plugin/in_http_pull.rb', line 105 def start super timer_execute(:in_http_pull, @interval, &method(:on_timer)) end |