eventstream

package module
v1.4.5 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2022 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeHeaders

func EncodeHeaders(w io.Writer, headers Headers) error

EncodeHeaders writes the header values to the writer encoded in the event stream format. Returns an error if a header fails to encode.

Types

type BoolValue

type BoolValue bool

An BoolValue provides eventstream encoding, and representation of a Go bool value.

func (BoolValue) Get

func (v BoolValue) Get() interface{}

Get returns the underlying type

func (BoolValue) String

func (v BoolValue) String() string

type BytesValue

type BytesValue []byte

An BytesValue provides eventstream encoding, and representation of a Go byte slice.

func (BytesValue) Get

func (v BytesValue) Get() interface{}

Get returns the underlying value.

func (BytesValue) String

func (v BytesValue) String() string

type ChecksumError

type ChecksumError struct{}

ChecksumError provides the error for message checksum invalidation errors.

func (ChecksumError) Error

func (e ChecksumError) Error() string

type Decoder

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

Decoder provides decoding of an Event Stream messages.

func NewDecoder

func NewDecoder(optFns ...func(*DecoderOptions)) *Decoder

NewDecoder initializes and returns a Decoder for decoding event stream messages from the reader provided.

func (*Decoder) Decode

func (d *Decoder) Decode(reader io.Reader, payloadBuf []byte) (m Message, err error)

Decode attempts to decode a single message from the event stream reader. Will return the event stream message, or error if decodeMessage fails to read the message from the stream.

payloadBuf is a byte slice that will be used in the returned Message.Payload. Callers must ensure that the Message.Payload from a previous decode has been consumed before passing in the same underlying payloadBuf byte slice.

type DecoderOptions

type DecoderOptions struct {
	Logger      logging.Logger
	LogMessages bool
}

DecoderOptions is the Decoder configuration options.

type Encoder

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

Encoder provides EventStream message encoding.

func NewEncoder

func NewEncoder(optFns ...func(*EncoderOptions)) *Encoder

NewEncoder initializes and returns an Encoder to encode Event Stream messages.

func (*Encoder) Encode

func (e *Encoder) Encode(w io.Writer, msg Message) (err error)

Encode encodes a single EventStream message to the io.Writer the Encoder was created with. An error is returned if writing the message fails.

type EncoderOptions

type EncoderOptions struct {
	Logger      logging.Logger
	LogMessages bool
}

EncoderOptions is the configuration options for Encoder.

type Header struct {
	Name  string
	Value Value
}

Header is a single EventStream Key Value header pair.

type Headers

type Headers []Header

Headers are a collection of EventStream header values.

func (Headers) Clone

func (hs Headers) Clone() Headers

Clone returns a deep copy of the headers

func (*Headers) Del

func (hs *Headers) Del(name string)

Del deletes the value in the Headers if it exists.

func (Headers) Get

func (hs Headers) Get(name string) Value

Get returns the Value associated with the header. Nil is returned if the value does not exist.

func (*Headers) Set

func (hs *Headers) Set(name string, value Value)

Set associates the name with a value. If the header name already exists in the Headers the value will be replaced with the new one.

type Int16Value

type Int16Value int16

An Int16Value provides eventstream encoding, and representation of a Go int16 value.

func (Int16Value) Get

func (v Int16Value) Get() interface{}

Get returns the underlying value.

func (Int16Value) String

func (v Int16Value) String() string

type Int32Value

type Int32Value int32

An Int32Value provides eventstream encoding, and representation of a Go int32 value.

func (Int32Value) Get

func (v Int32Value) Get() interface{}

Get returns the underlying value.

func (Int32Value) String

func (v Int32Value) String() string

type Int64Value

type Int64Value int64

An Int64Value provides eventstream encoding, and representation of a Go int64 value.

func (Int64Value) Get

func (v Int64Value) Get() interface{}

Get returns the underlying value.

func (Int64Value) String

func (v Int64Value) String() string

type Int8Value

type Int8Value int8

An Int8Value provides eventstream encoding, and representation of a Go int8 value.

func (Int8Value) Get

func (v Int8Value) Get() interface{}

Get returns the underlying value.

func (Int8Value) String

func (v Int8Value) String() string

type LengthError

type LengthError struct {
	Part  string
	Want  int
	Have  int
	Value interface{}
}

LengthError provides the error for items being larger than a maximum length.

func (LengthError) Error

func (e LengthError) Error() string

type Message

type Message struct {
	Headers Headers
	Payload []byte
}

A Message provides the eventstream message representation.

func (Message) Clone

func (m Message) Clone() Message

Clone returns a deep copy of the message.

type StringValue

type StringValue string

An StringValue provides eventstream encoding, and representation of a Go string.

func (StringValue) Get

func (v StringValue) Get() interface{}

Get returns the underlying value.

func (StringValue) String

func (v StringValue) String() string

type TimestampValue

type TimestampValue time.Time

An TimestampValue provides eventstream encoding, and representation of a Go timestamp.

func (TimestampValue) Get

func (v TimestampValue) Get() interface{}

Get returns the underlying value.

func (TimestampValue) MarshalJSON

func (v TimestampValue) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface

func (TimestampValue) String

func (v TimestampValue) String() string

type UUIDValue

type UUIDValue [16]byte

An UUIDValue provides eventstream encoding, and representation of a UUID value.

func (UUIDValue) Get

func (v UUIDValue) Get() interface{}

Get returns the underlying value.

func (UUIDValue) String

func (v UUIDValue) String() string

type Value

type Value interface {
	Get() interface{}
	String() string
	// contains filtered or unexported methods
}

Value represents the abstract header value.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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