Class: Aws::Binary::EventStreamDecoder Private

Inherits:
Object
  • Object
show all
Defined in:
lib/aws-sdk-core/binary/event_stream_decoder.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(protocol, rules, io, event_stream_handler = nil) ⇒ EventStreamDecoder

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

that registered with callbacks for processing events when they arrive

Parameters:

  • protocol (String)
  • rules (ShapeRef)

    ShapeRef of the eventstream member

  • event_stream_handler (EventStream|nil) (defaults to: nil)

    A Service EventStream object



12
13
14
15
16
17
18
# File 'lib/aws-sdk-core/binary/event_stream_decoder.rb', line 12

def initialize(protocol, rules, io, event_stream_handler = nil)
  @decoder = Aws::EventStream::Decoder.new
  @event_parser = EventParser.new(parser_class(protocol), rules)
  @stream_class = extract_stream_class(rules.shape.struct_class)
  @emitter = event_stream_handler.event_emitter
  @events = []
end

Instance Attribute Details

#eventsArray (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns events Array of arrived event objects.

Returns:

  • (Array)

    events Array of arrived event objects



21
22
23
# File 'lib/aws-sdk-core/binary/event_stream_decoder.rb', line 21

def events
  @events
end

Instance Method Details

#write(chunk) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



23
24
25
26
27
28
29
30
31
# File 'lib/aws-sdk-core/binary/event_stream_decoder.rb', line 23

def write(chunk)
  raw_event, eof = @decoder.decode_chunk(chunk)
  emit_event(raw_event) if raw_event
  while !eof
    # exhaust message_buffer data
    raw_event, eof = @decoder.decode_chunk
    emit_event(raw_event) if raw_event
  end
end