message

package
v0.5.7 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUndefinedDataType       = errors.New("undefined message data types")
	ErrInvalidMessageFieldType = errors.New("invalid message field type")
	ErrFieldNotFound           = errors.New("field not found")
)

Errors set

Functions

This section is empty.

Types

type FieldType

type FieldType int

FieldType of data represents scalar types supported by eventstream message processing

const (
	FieldTypeString FieldType = iota
	FieldTypeFixed
	FieldTypeUUID
	FieldTypeInt
	FieldTypeInt8
	FieldTypeInt32
	FieldTypeInt64
	FieldTypeUint
	FieldTypeUint8
	FieldTypeUint32
	FieldTypeUint64
	FieldTypeFloat
	FieldTypeBoolean
	FieldTypeIP
	FieldTypeDate
	FieldTypeUnixnano
	FieldTypeArrayInt32
	FieldTypeArrayInt64
)

Field scalar types enum

func TypeByString

func TypeByString(t string) FieldType

TypeByString name

func (FieldType) Cast

func (t FieldType) Cast(v any) any

Cast value into the fieldType

func (FieldType) CastExt added in v0.4.3

func (t FieldType) CastExt(v any, length int, format string) any

CastExt with additional conditions

func (FieldType) String

func (t FieldType) String() string

String implementaion of fmt.Stringer

type Formater

type Formater interface {
	Format(msg Message) (any, error)
}

Formater processor

type MapMessage added in v0.5.2

type MapMessage map[string]any

Map object

func MapMessageDecode added in v0.5.2

func MapMessageDecode(data []byte, converter unmarshalel) (msg MapMessage, err error)

MessageDecode from bytes

func (MapMessage) Get added in v0.5.2

func (m MapMessage) Get(name string) (any, error)

Get returns the value by key name

func (MapMessage) Item added in v0.5.2

func (m MapMessage) Item(key string, def any) any

Item returns the value by key name or default

func (MapMessage) ItemCast added in v0.5.2

func (m MapMessage) ItemCast(key string, fieldType FieldType, length int, format string) any

ItemCast converts any key value into the field_type

func (MapMessage) JSON added in v0.5.2

func (m MapMessage) JSON() string

JSON data string

func (MapMessage) Map added in v0.5.2

func (m MapMessage) Map() map[string]any

Map returns the message as map[string]any

func (MapMessage) Str added in v0.5.2

func (m MapMessage) Str(key, def string) string

Str returns the string value by key name or default

type Message

type Message interface {
	Get(name string) (any, error)
	Item(key string, def any) any
	ItemCast(key string, fieldType FieldType, length int, format string) any
	Str(key, def string) string
	JSON() string
	Map() map[string]any
}

Message interface TODO: refactor this interface

var EmptyMessage Message = (*dummyMessage)(nil)

Jump to

Keyboard shortcuts

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