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, output_ref, error_refs, 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

  • output_ref (ShapeRef)

    ShapeRef of output shape

  • error_refs (Array)

    array of ShapeRefs for errors

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

    A Service EventStream object



16
17
18
19
20
21
22
# File 'lib/aws-sdk-core/binary/event_stream_decoder.rb', line 16

def initialize(protocol, rules, output_ref, error_refs, io, event_stream_handler = nil)
  @decoder = Aws::EventStream::Decoder.new
  @event_parser = EventParser.new(parser_class(protocol), rules, error_refs, output_ref)
  @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



25
26
27
# File 'lib/aws-sdk-core/binary/event_stream_decoder.rb', line 25

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.



27
28
29
30
31
32
33
34
35
# File 'lib/aws-sdk-core/binary/event_stream_decoder.rb', line 27

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