Class: Aws::Binary::EventStreamEncoder Private

Inherits:
Object
  • Object
show all
Defined in:
lib/aws-sdk-core/binary/event_stream_encoder.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, input_ref, signer) ⇒ EventStreamEncoder

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 a new instance of EventStreamEncoder.

Parameters:

  • protocol (String)
  • rules (ShapeRef)

    ShapeRef of the eventstream member

  • input_ref (ShapeRef)

    ShapeRef of the input shape

  • signer (Aws::Sigv4::Signer)


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

def initialize(protocol, rules, input_ref, signer)
  @encoder = Aws::EventStream::Encoder.new
  @event_builder = EventBuilder.new(serializer_class(protocol), rules)
  @input_ref = input_ref
  @rules = rules
  @signer = signer
  @prior_signature = nil
end

Instance Attribute Details

#prior_signatureObject

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.



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

def prior_signature
  @prior_signature
end

#rulesObject (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.



23
24
25
# File 'lib/aws-sdk-core/binary/event_stream_encoder.rb', line 23

def rules
  @rules
end

Instance Method Details

#encode(event_type, params) ⇒ 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
36
37
38
39
40
# File 'lib/aws-sdk-core/binary/event_stream_encoder.rb', line 27

def encode(event_type, params)
  if event_type == :end_stream
    payload = ''
  else
    payload = @encoder.encode(@event_builder.apply(event_type, params))
  end
  headers, signature = @signer.sign_event(@prior_signature, payload, @encoder)
  @prior_signature = signature
  message = Aws::EventStream::Message.new(
    headers: headers,
    payload: StringIO.new(payload)
  )
  @encoder.encode(message)
end