eventstreamapi

package
v1.14.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2018 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	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.

Variables

This section is empty.

Functions

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 EventReader

type EventReader struct {
	// contains filtered or unexported fields
}

EventReader provides reading from the EventStream of an reader.

func NewEventReader

func NewEventReader(
	reader io.ReadCloser,
	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) Close

func (r *EventReader) Close() error

Close closes the EventReader's EventStream reader.

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.

func (*EventReader) UseLogger

func (r *EventReader) UseLogger(logger aws.Logger, logLevel aws.LogLevelType)

UseLogger instructs the EventReader to use the logger and log level specified.

type Unmarshaler

type Unmarshaler interface {
	UnmarshalEvent(protocol.PayloadUnmarshaler, eventstream.Message) error
}

Unmarshaler provides the interface for unmarshaling a EventStream message into a SDK type.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL