Class: GroqRuby::Streaming::EventParser
- Inherits:
-
Object
- Object
- GroqRuby::Streaming::EventParser
- Defined in:
- lib/groq_ruby/streaming/event_parser.rb
Overview
Thin adapter over the upstream ‘event_stream_parser` gem. Feeds raw response chunks in and yields parsed `(event, data, id, retry)` tuples. Single-purpose: it owns the SSE parser state and nothing else.
Instance Method Summary collapse
-
#feed(chunk) {|event, data, id, reconnect_time| ... } ⇒ Object
Feed a raw chunk from the HTTP response.
-
#initialize ⇒ EventParser
constructor
A new instance of EventParser.
Constructor Details
#initialize ⇒ EventParser
Returns a new instance of EventParser.
9 10 11 |
# File 'lib/groq_ruby/streaming/event_parser.rb', line 9 def initialize @parser = ::EventStreamParser::Parser.new end |
Instance Method Details
#feed(chunk) {|event, data, id, reconnect_time| ... } ⇒ Object
Feed a raw chunk from the HTTP response. Yields each parsed event.
18 19 20 |
# File 'lib/groq_ruby/streaming/event_parser.rb', line 18 def feed(chunk, &block) @parser.feed(chunk, &block) end |