Class: Gelfd::ChunkedParser
- Inherits:
-
Object
- Object
- Gelfd::ChunkedParser
- Defined in:
- lib/gelfd/chunked_parser.rb
Constant Summary collapse
- @@chunk_map =
Hash.new {|hash,key| hash[key] = {:total_chunks => 0, :chunks => {} } }
Instance Attribute Summary collapse
-
#chunks ⇒ Object
Returns the value of attribute chunks.
-
#decoded_data ⇒ Object
Returns the value of attribute decoded_data.
-
#max_chunks ⇒ Object
Returns the value of attribute max_chunks.
-
#message_id ⇒ Object
Returns the value of attribute message_id.
-
#seen ⇒ Object
Returns the value of attribute seen.
Class Method Summary collapse
Instance Attribute Details
#chunks ⇒ Object
Returns the value of attribute chunks.
5 6 7 |
# File 'lib/gelfd/chunked_parser.rb', line 5 def chunks @chunks end |
#decoded_data ⇒ Object
Returns the value of attribute decoded_data.
5 6 7 |
# File 'lib/gelfd/chunked_parser.rb', line 5 def decoded_data @decoded_data end |
#max_chunks ⇒ Object
Returns the value of attribute max_chunks.
5 6 7 |
# File 'lib/gelfd/chunked_parser.rb', line 5 def max_chunks @max_chunks end |
#message_id ⇒ Object
Returns the value of attribute message_id.
5 6 7 |
# File 'lib/gelfd/chunked_parser.rb', line 5 def @message_id end |
#seen ⇒ Object
Returns the value of attribute seen.
5 6 7 |
# File 'lib/gelfd/chunked_parser.rb', line 5 def seen @seen end |
Class Method Details
.assemble_chunks(msg_id) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/gelfd/chunked_parser.rb', line 14 def self.assemble_chunks(msg_id) buff = '' chunks = @@chunk_map[msg_id][:chunks] chunks.keys.sort.each do |k| buff += chunks[k] end begin # TODO # This has a chance for an DoS # you can send a chunked message as a chunked message t = Parser.parse(buff.clone) @@chunk_map.delete(msg_id) t rescue Exception => e "Exception: #{e.}" end end |
.parse(data) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/gelfd/chunked_parser.rb', line 7 def self.parse(data) msg_id = self.parse_chunk(data) if @@chunk_map[msg_id][:chunks].size == @@chunk_map[msg_id][:total_chunks] assemble_chunks(msg_id) end end |