Class: Fluent::Compat::ExecUtil::JSONParser
- Defined in:
- lib/fluent/compat/exec_util.rb
Constant Summary collapse
- BYTES_TO_READ =
8192
Instance Method Summary collapse
Methods inherited from Parser
Constructor Details
This class inherits a constructor from Fluent::Compat::ExecUtil::Parser
Instance Method Details
#call(io) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/fluent/compat/exec_util.rb', line 82 def call(io) parser = JSON::ResumableParser.new(**Fluent::DEFAULT_JSON_PARSE_OPTIONS) begin chunk = +"".b while io.readpartial(BYTES_TO_READ, chunk) parser << chunk while parser.parse @on_message.call(parser.value) end end rescue EOFError unless parser.empty? $log&.warn "JSON stream ended in the middle of a document; " \ "discarding incomplete data" end end end |