Data represents valid types that can be used in sdt.Map and sdt.Stream instances. Valid types are: int, uint, nil, bool, uint8, uint16, uint32, uint64, int8, int16, int32, int64, string, rune, float32, float64, byte, []byte, sdt.WChar, resource.Destination, sdt.Map and sdt.Stream.
Message type mapping is as follows: solClient_fieldType Golang Type SOLCLIENT_BOOL bool SOLCLIENT_UINT8 uint8 SOLCLIENT_INT8 int8 SOLCLIENT_UINT16 uint16 SOLCLIENT_INT16 int16 SOLCLIENT_UINT32 uint32 SOLCLIENT_INT32 int32 SOLCLIENT_UINT64 uint64 SOLCLIENT_INT64 int64 SOLCLIENT_WCHAR sdt.WChar SOLCLIENT_STRING string SOLCLIENT_BYTEARRAY []byte SOLCLIENT_FLOAT float32 SOLCLIENT_DOUBLE float64 SOLCLIENT_MAP sdt.Map SOLCLIENT_STREAM sdt.Stream SOLCLIENT_NULL nil SOLCLIENT_DESTINATION solace.Destination (solace.Queue or solace.Topic) SOLCLIENT_UNKNOWN []byte
On outbound messages, the following additional types are supported with the following mappings:
byte SOLCLIENT_INT8 int SOLCLIENT_INT64 uint SOLCLIENT_UINT64 rune SOLCLIENT_INT32
Notes on mappings:
- int is always be converted to int64, even when on 32-bit architectures
- uint is always be converted to uint64, even when on 32-bit architectures
- byte is the same as int8 and is mapped accordingly
In addition to these mappings, client-side conversions may be made to retrieve data in the type you want. The following table is used to determine these conversions:
Type | bool | byte | int | uint | uint8 | int8 | uint16 | int16 | uint32 | int32 | uint64 | int64 | []byte | float32 | float64 | string | WChar | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- bool | x x x x x x x x x x x x x byte | x x x x x x x x x x x x x int | x x x x x x x x x x x x x uint | x x x x x x x x x x x x x uint8 | x x x x x x x x x x x x x int8 | x x x x x x x x x x x x x uint16 | x x x x x x x x x x x x x int16 | x x x x x x x x x x x x x uint32 | x x x x x x x x x x x x x int32 | x x x x x x x x x x x x x uint64 | x x x x x x x x x x x x x int64 | x x x x x x x x x x x x x []byte | x x float32 | x x float64 | x x string | x x WChar | x x x x
For each integer-type conversion, the value will be converted if it is within the range of the requested type, otherwise a conversion error will be thrown indicating that the value is outside the domain. String types will be converted to integers using strconv.Stoi and then returned if it is within the range of the requested type. For boolean conversions from integer types, all non-zero values map to true. For boolean conversion from strings, "true" and "1" map to true, "false" and "0" map to false, and all other strings are not converted. WChar conversion converts strings of length 1 into a WChar. All other strings are rejected.
In addition, the following one-to-one conversions are used:
sdt.Map, sdt.Stream
Lastly, Destination is mapped with these getters:
GetQueue, GetTopic, and GetDestination
type Data interface{}
FormatConversionError is returned if there is an error converting stored data to a specified return type.
type FormatConversionError struct { // Message is the message of the error Message string // Data is the data that could not be converted. Data interface{} }
func (err *FormatConversionError) Error() string
Error implements the error interface and returns the error message as string.
IllegalTypeError is returned if an error occurs while encoding a stored type to a message when setting a payload or user property.
type IllegalTypeError struct { Data interface{} }
func (err *IllegalTypeError) Error() string
Error implements the error interface and returns the error message as string.
KeyNotFoundError is returned if the requested key is not found.
type KeyNotFoundError struct { // Key is the key that was being accessed and does not exist. Key string }
func (err *KeyNotFoundError) Error() string
Map represents a map between strings and values that can be converted into structured data types in a message payload. Accepts any valid sdt.Data types.
type Map map[string]Data
func (sdtMap Map) GetBool(key string) (val bool, err error)
GetBool retrieves the data using the specified key and attempts to convert the data into a boolean form, if necessary. Returns the boolean value of the field, and one of the following errors if it occurred:
- sdt.KeyNotFoundError - If a mapping for the specified key was not found.
- sdt.FormatConversionError - If the data cannot be converted into boolean form.
func (sdtMap Map) GetByte(key string) (val byte, err error)
GetByte retrieves the data at the specified key and attempt to convert the data into byte form if necessary. Returns the byte value of the field, and one of the following errors if it occurred:
- sdt.KeyNotFoundError - If a mapping for the specified key was not found.
- sdt.FormatConversionError - If the data cannot be converted into byte form.
func (sdtMap Map) GetByteArray(key string) (val []byte, err error)
GetByteArray retrieves the data at the specified key and attempt to convert the data into []byte form if necessary. Returns the []byte value of the field, and one of the following errors if it occurred:
- sdt.KeyNotFoundError - If a mapping for the specified key was not found.
- sdt.FormatConversionError - If the data cannot be converted into []byte form.
func (sdtMap Map) GetDestination(key string) (val resource.Destination, err error)
GetDestination retrieves the data at the specified key as a Destination. One of the following errors may occur:
- sdt.KeyNotFoundError - If a mapping for the specified key was not found.
- sdt.FormatConversionError - If the data is not of type Destination.
func (sdtMap Map) GetFloat32(key string) (val float32, err error)
GetFloat32 retrieves the data at the specified key and attempt to convert the data into float32 form if necessary. Returns the float32 value of the field, and one of the following errors if it occurred:
- sdt.KeyNotFoundError - If a mapping for the specified key was not found.
- sdt.FormatConversionError - If the data cannot be converted into float32 form.
func (sdtMap Map) GetFloat64(key string) (val float64, err error)
GetFloat64 retrieves the data at the specified key and attempt to convert the data into float64 form if necessary. Returns the float64 value of the field, and one of the following errors if it occurred:
- sdt.KeyNotFoundError - If a mapping for the specified key was not found.
- sdt.FormatConversionError - If the data cannot be converted into float64 form.
func (sdtMap Map) GetInt(key string) (val int, err error)
GetInt retrieves the data at the specified key and attempt to convert the data into int form if necessary. Returns the int value of the field, and one of the following errors if it occurred:
- sdt.KeyNotFoundError - If a mapping for the specified key was not found.
- sdt.FormatConversionError - If the data cannot be converted into int form.
func (sdtMap Map) GetInt16(key string) (val int16, err error)
GetInt16 retrieves the data at the specified key and attempt to convert the data into int16 form if necessary. Returns the int16 value of the field, and one of the following errors if it occurred:
- sdt.KeyNotFoundError - If a mapping for the specified key was not found.
- sdt.FormatConversionError - If the data cannot be converted into int16 form.
func (sdtMap Map) GetInt32(key string) (val int32, err error)
GetInt32 retrieves the data at the specified key and attempt to convert the data into int32 form if necessary. Returns the int32 value of the field, and one of the following errors if it occurred:
- sdt.KeyNotFoundError - If a mapping for the specified key was not found.
- sdt.FormatConversionError - If the data cannot be converted into int32 form.
func (sdtMap Map) GetInt64(key string) (val int64, err error)
GetInt64 retrieves the data at the specified key and attempt to convert the data into int64 form if necessary. Returns the int64 value of the field, and one of the following errors if it occurred:
- sdt.KeyNotFoundError - If a mapping for the specified key was not found.
- sdt.FormatConversionError - If the data cannot be converted into int64 form.
func (sdtMap Map) GetInt8(key string) (val int8, err error)
GetInt8 retrieves the data at the specified key and attempt to convert the data into int8 form if necessary. Returns the int8 value of the field, and one of the following errors if it occurred:
- sdt.KeyNotFoundError - If a mapping for the specified key was not found.
- sdt.FormatConversionError - If the data cannot be converted into int8 form.
func (sdtMap Map) GetMap(key string) (val Map, err error)
GetMap retrieves the data at the specified key as an sdt.Map. One of the following errors may occur:
- sdt.KeyNotFoundError - If a mapping for the specified key was not found.
- sdt.FormatConversionError - If the data is not of type sdt.Map.
func (sdtMap Map) GetQueue(key string) (val *resource.Queue, err error)
GetQueue retrieves the data at the specified key as a Queue. One of the following errors may occur:
- sdt.KeyNotFoundError - If a mapping for the specified key was not found.
- sdt.FormatConversionError - If the data is not of type Queue.
func (sdtMap Map) GetStream(key string) (val Stream, err error)
GetStream retrieves the data at the specified key as an sdt.Stream. One of the following errors may occur:
- sdt.KeyNotFoundError - If a mapping for the specified key was not found.
- sdt.FormatConversionError - If the data is not of type sdt.Stream.
func (sdtMap Map) GetString(key string) (val string, err error)
GetString retrieves the data at the specified key and attempt to convert the data into string form if necessary. Returns the string value of the field, and one of the following errors if it occurred:
- sdt.KeyNotFoundError - If a mapping for the specified key was not found.
- sdt.FormatConversionError - If the data cannot be converted into string form.
func (sdtMap Map) GetTopic(key string) (val *resource.Topic, err error)
GetTopic retrieves the data at the specified key as a Topic. One of the following errors may occur:
- sdt.KeyNotFoundError - If a mapping for the specified key was not found.
- sdt.FormatConversionError - If the data is not of type Topic.
func (sdtMap Map) GetUInt(key string) (val uint, err error)
GetUInt retrieves the data at the specified key and attempt to convert the data into uint form if necessary. Returns the uint value of the field, and one of the following errors if it occurred:
- sdt.KeyNotFoundError - If a mapping for the specified key was not found.
- sdt.FormatConversionError - If the data cannot be converted into uint form.
func (sdtMap Map) GetUInt16(key string) (val uint16, err error)
GetUInt16 retrieves the data at the specified key and attempt to convert the data into uint16 form if necessary. Returns the uint16 value of the field, and one of the following errors if it occurred:
- sdt.KeyNotFoundError if a mapping for the specified key was not found.
- sdt.FormatConversionError - If the data cannot be converted into uint16 form.
func (sdtMap Map) GetUInt32(key string) (val uint32, err error)
GetUInt32 retrieves the data at the specified key and attempt to convert the data into uint32 form if necessary. Returns the uint32 value of the field, and one of the following errors if it occurred:
- sdt.KeyNotFoundError - If a mapping for the specified key was not found.
- sdt.FormatConversionError if the data cannot be converted into uint32 form.
func (sdtMap Map) GetUInt64(key string) (val uint64, err error)
GetUInt64 retrieves the data at the specified key and attempt to convert the data into uint64 form if necessary. Returns the uint64 value of the field, and one of the following errors if it occurred:
- sdt.KeyNotFoundError - If a mapping for the specified key was not found.
- sdt.FormatConversionError - If the data cannot be converted into uint64 form
func (sdtMap Map) GetUInt8(key string) (val uint8, err error)
GetUInt8 retrieves the data at the specified key and attempt to convert the data into uint8 form if necessary. Returns the uint8 value of the field, and one of the following errors if it occurred:
- sdt.KeyNotFoundError - If a mapping for the specified key was not found.
- sdt.FormatConversionError - If the data cannot be converted into uint8 form.
func (sdtMap Map) GetWChar(key string) (val WChar, err error)
GetWChar retrieves the data at the specified key and attempt to convert the data into WChar form if necessary. Returns the WChar value of the field, and one of the following errors if it occurred:
- sdt.KeyNotFoundError - If a mapping for the specified key was not found.
- sdt.FormatConversionError - If the data cannot be converted into WChar form.
OutOfBoundsError is returned if the specified index is out of bounds.
type OutOfBoundsError struct { Index int }
func (err *OutOfBoundsError) Error() string
Stream represents a stream of data that can be converted into structured data types in a message payload. Accepts any valid sdt.Data types.
type Stream []Data
func (sdtStream Stream) GetBool(index int) (val bool, err error)
GetBool retrieves the data at the specified index and attempt to convert the data into boolean form if necessary. Returns the boolean value of the field, and one of the following errors if it occurred:
- sdt.OutOfBoundsError - If the specified index is out of the stream's bounds.
- sdt.FormatConversionError - If the data cannot be converted into boolean form.
func (sdtStream Stream) GetByte(index int) (val byte, err error)
GetByte retrieves the data at the specified index and attempt to convert the data into byte form if necessary. Returns the byte value of the field, and one of the following errors if it occurred:
- sdt.OutOfBoundsError - If the specified index is out of the stream's bounds.
- sdt.FormatConversionError - If the data cannot be converted into byte form.
func (sdtStream Stream) GetByteArray(index int) (val []byte, err error)
GetByteArray retrieves the data at the specified index and attempt to convert the data into []byte form if necessary. Returns the []byte value of the field, and one of the following errors if it occurred:
- sdt.OutOfBoundsError - If the specified index is out of the stream's bounds.
- sdt.FormatConversionError - If the data cannot be converted into []byte form.
func (sdtStream Stream) GetDestination(index int) (val resource.Destination, err error)
GetDestination retrieves the data at the specified index as a Destination. One of the following errors may occur:
- sdt.OutOfBoundsError - If the specified index is out of the stream's bounds.
- sdt.FormatConversionError - If the data is not of type Destination.
func (sdtStream Stream) GetFloat32(index int) (val float32, err error)
GetFloat32 retrieves the data at the specified index and attempt to convert the data into float32 form if necessary. Returns the float32 value of the field, and one of the following errors if it occurred:
- sdt.OutOfBoundsError - If the specified index is out of the stream's bounds.
- sdt.FormatConversionError - If the data cannot be converted into float32 form.
func (sdtStream Stream) GetFloat64(index int) (val float64, err error)
GetFloat64 retrieves the data at the specified index and attempt to convert the data into float64 form if necessary. Returns the float64 value of the field, and one of the following errors if it occurred:
- sdt.OutOfBoundsError - If the specified index is out of the stream's bounds.
- sdt.FormatConversionError - If the data cannot be converted into float64 form.
func (sdtStream Stream) GetInt(index int) (val int, err error)
GetInt retrieves the data at the specified index and attempt to convert the data into int form if necessary. Returns the int value of the field, and one of the following errors if it occurred:
- sdt.OutOfBoundsError - If the specified index is out of the stream's bounds.
- sdt.FormatConversionError - If the data cannot be converted into int form.
func (sdtStream Stream) GetInt16(index int) (val int16, err error)
GetInt16 retrieves the data at the specified index and attempt to convert the data into int16 form if necessary. Returns the int16 value of the field, and one of the following errors if it occurred:
- sdt.OutOfBoundsError - If the specified index is out of the stream's bounds.
- sdt.FormatConversionError - If the data cannot be converted into int16 form.
func (sdtStream Stream) GetInt32(index int) (val int32, err error)
GetInt32 retrieves the data at the specified index and attempt to convert the data into int32 form if necessary. Returns the int32 value of the field, and one of the following errors if it occurred:
- sdt.OutOfBoundsError - If the specified index is out of the stream's bounds.
- sdt.FormatConversionError - If the data cannot be converted into int32 form.
func (sdtStream Stream) GetInt64(index int) (val int64, err error)
GetInt64 retrieves the data at the specified index and attempt to convert the data into int64 form if necessary. Returns the int64 value of the field, and one of the following errors if it occurred:
- sdt.OutOfBoundsError - If the specified index is out of the stream's bounds.
- sdt.FormatConversionError - If the data cannot be converted into int64 form.
func (sdtStream Stream) GetInt8(index int) (val int8, err error)
GetInt8 retrieves the data at the specified index and attempt to convert the data into int8 form if necessary. Returns the int8 value of the field, and one of the following errors if it occurred:
- sdt.OutOfBoundsError - If the specified index is out of the stream's bounds.
- sdt.FormatConversionError - If the data cannot be converted into int8 form.
func (sdtStream Stream) GetMap(index int) (val Map, err error)
GetMap retrieves the data at the specified index as an sdt.Map. One of the following errors may occur:
- sdt.OutOfBoundsError - If the specified index is out of the stream's bounds.
- sdt.FormatConversionError - If the data is not of type sdt.Map.
func (sdtStream Stream) GetQueue(index int) (val *resource.Queue, err error)
GetQueue retrieves the data at the specified index as a Queue. One of the following errors may occur:
- sdt.OutOfBoundsError - If the specified index is out of the stream's bounds.
- sdt.FormatConversionError - If the data is not of type Queue.
func (sdtStream Stream) GetStream(index int) (val Stream, err error)
GetStream retrieves the data at the specified index as an sdt.Stream. One of the following errors may occur:
- sdt.OutOfBoundsError - If the specified index is out of the stream's bounds.
- sdt.FormatConversionError - If the data is not of type sdt.Stream.
func (sdtStream Stream) GetString(index int) (val string, err error)
GetString retrieves the data at the specified index and attempt to convert the data into string form if necessary. Returns the string value of the field, and one of the following errors if it occurred:
- sdt.OutOfBoundsError - If the specified index is out of the stream's bounds.
- sdt.FormatConversionError - If the data cannot be converted into string form.
func (sdtStream Stream) GetTopic(index int) (val *resource.Topic, err error)
GetTopic retrieves the data at the specified index as a Topic. One of the following errors may occur:
- sdt.OutOfBoundsError - If the specified index is out of the stream's bounds.
- sdt.FormatConversionError - If the data is not of type Topic.
func (sdtStream Stream) GetUInt(index int) (val uint, err error)
GetUInt retrieves the data at the specified index and attempt to convert the data into uint form if necessary. Returns the uint value of the field, and one of the following errors if it occurred:
- sdt.OutOfBoundsError - If the specified index is out of the stream's bounds.
- sdt.FormatConversionError - If the data cannot be converted into uint form.
func (sdtStream Stream) GetUInt16(index int) (val uint16, err error)
GetUInt16 retrieves the data at the specified index and attempt to convert the data into uint16 form if necessary. Returns the uint16 value of the field, and one of the following errors if it occurred:
- sdt.OutOfBoundsError - If the specified index is out of the stream's bounds.
- sdt.FormatConversionError - If the data cannot be converted into uint16 form.
func (sdtStream Stream) GetUInt32(index int) (val uint32, err error)
GetUInt32 retrieves the data at the specified index and attempt to convert the data into uint32 form if necessary. Returns the uint32 value of the field, and one of the following errors if it occurred:
- sdt.OutOfBoundsError - If the specified index is out of the stream's bounds.
- sdt.FormatConversionError - If the data cannot be converted into uint32 form.
func (sdtStream Stream) GetUInt64(index int) (val uint64, err error)
GetUInt64 retrieves the data at the specified index and attempt to convert the data into uint64 form if necessary. Returns the uint64 value of the field, and one of the following errors if it occurred:
- sdt.OutOfBoundsError - If the specified index is out of the stream's bounds.
- sdt.FormatConversionError - If the data cannot be converted into uint64 form.
func (sdtStream Stream) GetUInt8(index int) (val uint8, err error)
GetUInt8 retrieves the data at the specified index and attempt to convert the data into uint8 form if necessary. Returns the uint8 value of the field, and one of the following errors if it occurred:
- sdt.OutOfBoundsError - If the specified index is out of the stream's bounds.
- sdt.FormatConversionError - If the data cannot be converted into uint8 form.
func (sdtStream Stream) GetWChar(index int) (val WChar, err error)
GetWChar retrieves the data at the specified index and attempt to convert the data into WChar form if necessary. Returns the WChar value of the field, and one of the following errors if it occurred:
- sdt.OutOfBoundsError - If the specified index is out of the stream's bounds.
- sdt.FormatConversionError - If the data cannot be converted into WChar form.
WChar represents the wide character type. WChar is a uint16 value holding UTF-16 data. On publish, this value is converted into SOLCLIENT_WCHAR, and on receive SOLCLIENT_WCHAR is converted into WChar.
type WChar uint16