Documentation ¶
Index ¶
- Constants
- func ApplyHTTPTransportFixes(r *request.Request)
- func GetHeaderString(msg eventstream.Message, headerName string) (string, error)
- type BufferEncoder
- type Encoder
- type EventReader
- type EventWriter
- type Marshaler
- type OnceError
- type SignEncoder
- type StreamSigner
- type StreamWriter
- type UnknownMessageTypeError
- type Unmarshaler
Constants ¶
const ( ChunkSignatureHeader = `:chunk-signature` // chunk signature for message DateHeader = `:date` // Date header for signature // Message header and values MessageTypeHeader = `:message-type` // Identifies type of message. EventMessageType = `event` ErrorMessageType = `error` ExceptionMessageType = `exception` // Message Events EventTypeHeader = `:event-type` // Identifies message event type e.g. "Stats". // Message Error ErrorCodeHeader = `:error-code` ErrorMessageHeader = `:error-message` // Message Exception ExceptionTypeHeader = `:exception-type` )
EventStream headers with specific meaning to async API functionality.
const InputWriterCloseErrorCode = "EventStreamInputWriterCloseError"
InputWriterCloseErrorCode is used to denote an error occurred while closing the event stream input writer.
Variables ¶
This section is empty.
Functions ¶
func ApplyHTTPTransportFixes ¶ added in v1.9.3
ApplyHTTPTransportFixes is a no-op for Go 1.18 and above.
func GetHeaderString ¶
func GetHeaderString(msg eventstream.Message, headerName string) (string, error)
GetHeaderString returns the value of the header as a string. If the header is not set or the value is not a string an error will be returned.
Types ¶
type BufferEncoder ¶ added in v1.3.2
type BufferEncoder struct {
// contains filtered or unexported fields
}
BufferEncoder is a utility that provides a buffered event stream encoder
func NewBufferEncoder ¶ added in v1.3.2
func NewBufferEncoder() *BufferEncoder
NewBufferEncoder returns a new BufferEncoder initialized with a 1024 byte buffer.
func (*BufferEncoder) Encode ¶ added in v1.3.2
func (e *BufferEncoder) Encode(msg eventstream.Message) ([]byte, error)
Encode returns the encoded message as a byte slice. The returned byte slice will be modified on the next encode call and should not be held onto.
type Encoder ¶ added in v1.3.2
type Encoder interface {
Encode(eventstream.Message) error
}
Encoder is an stream encoder that will encode an event stream message for the transport.
type EventReader ¶
type EventReader struct {
// contains filtered or unexported fields
}
EventReader provides reading from the EventStream of an reader.
func NewEventReader ¶
func NewEventReader( decoder *eventstream.Decoder, payloadUnmarshaler protocol.PayloadUnmarshaler, unmarshalerForEventType func(string) (Unmarshaler, error), ) *EventReader
NewEventReader returns a EventReader built from the reader and unmarshaler provided. Use ReadStream method to start reading from the EventStream.
func (*EventReader) ReadEvent ¶
func (r *EventReader) ReadEvent() (event interface{}, err error)
ReadEvent attempts to read a message from the EventStream and return the unmarshaled event value that the message is for.
For EventStream API errors check if the returned error satisfies the awserr.Error interface to get the error's Code and Message components.
EventUnmarshalers called with EventStream messages must take copies of the message's Payload. The payload will is reused between events read.
type EventWriter ¶ added in v1.3.2
type EventWriter struct {
// contains filtered or unexported fields
}
EventWriter provides a wrapper around the underlying event stream encoder for an io.WriteCloser.
func NewEventWriter ¶ added in v1.3.2
func NewEventWriter(encoder Encoder, pm protocol.PayloadMarshaler, eventTypeFor func(Marshaler) (string, error), ) *EventWriter
NewEventWriter returns a new event stream writer, that will write to the writer provided. Use the WriteEvent method to write an event to the stream.
func (*EventWriter) WriteEvent ¶ added in v1.3.2
func (w *EventWriter) WriteEvent(event Marshaler) error
WriteEvent writes an event to the stream. Returns an error if the event fails to marshal into a message, or writing to the underlying writer fails.
type Marshaler ¶ added in v1.3.2
type Marshaler interface {
MarshalEvent(protocol.PayloadMarshaler) (eventstream.Message, error)
}
Marshaler provides a marshaling interface for event types to event stream messages.
type OnceError ¶ added in v1.3.2
type OnceError struct {
// contains filtered or unexported fields
}
OnceError wraps the behavior of recording an error once and signal on a channel when this has occurred. Signaling is done by closing of the channel.
Type is safe for concurrent usage.
func NewOnceError ¶ added in v1.3.2
func NewOnceError() *OnceError
NewOnceError return a new OnceError
func (*OnceError) Err ¶ added in v1.3.2
Err acquires a read-lock and returns an error if one has been set.
type SignEncoder ¶ added in v1.3.2
type SignEncoder struct {
// contains filtered or unexported fields
}
SignEncoder envelopes event stream messages into an event stream message payload with included signature headers using the provided signer and encoder.
func NewSignEncoder ¶ added in v1.3.2
func NewSignEncoder(signer StreamSigner, encoder Encoder) *SignEncoder
NewSignEncoder returns a new SignEncoder using the provided stream signer and event stream encoder.
func (*SignEncoder) Close ¶ added in v1.3.2
func (s *SignEncoder) Close() error
Close encodes a final event stream signing envelope with an empty event stream payload. This final end-frame is used to mark the conclusion of the stream.
func (*SignEncoder) Encode ¶ added in v1.3.2
func (s *SignEncoder) Encode(msg eventstream.Message) error
Encode takes the provided message and add envelopes the message with the required signature.
type StreamSigner ¶ added in v1.3.2
type StreamSigner interface {
GetSignature(headers, payload []byte, date time.Time) ([]byte, error)
}
StreamSigner defines an interface for the implementation of signing of event stream payloads
type StreamWriter ¶ added in v1.3.2
type StreamWriter struct {
// contains filtered or unexported fields
}
StreamWriter provides concurrent safe writing to an event stream.
func NewStreamWriter ¶ added in v1.3.2
func NewStreamWriter(eventWriter *EventWriter, streamCloser io.Closer) *StreamWriter
NewStreamWriter returns a StreamWriter for the event writer, and stream closer provided.
func (*StreamWriter) Close ¶ added in v1.3.2
func (w *StreamWriter) Close() error
Close terminates the writers ability to write new events to the stream. Any future call to Send will fail with an error.
func (*StreamWriter) Err ¶ added in v1.3.2
func (w *StreamWriter) Err() error
Err returns any error that occurred while attempting to write an event to the stream.
func (*StreamWriter) ErrorSet ¶ added in v1.3.2
func (w *StreamWriter) ErrorSet() <-chan struct{}
ErrorSet returns a channel which will be closed if an error occurs.
type UnknownMessageTypeError ¶ added in v1.7.0
type UnknownMessageTypeError struct { Type string Message eventstream.Message }
UnknownMessageTypeError provides an error when a message is received from the stream, but the reader is unable to determine what kind of message it is.
func (*UnknownMessageTypeError) Error ¶ added in v1.7.0
func (e *UnknownMessageTypeError) Error() string
type Unmarshaler ¶
type Unmarshaler interface {
UnmarshalEvent(protocol.PayloadUnmarshaler, eventstream.Message) error
}
Unmarshaler provides the interface for unmarshaling a EventStream message into a SDK type.