message

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: May 28, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateRandomID

func GenerateRandomID() ([]byte, error)

Types

type JsonMessage

type JsonMessage[T any] struct {
	// contains filtered or unexported fields
}

func (*JsonMessage[T]) Data

func (m *JsonMessage[T]) Data() T

func (*JsonMessage[T]) ID

func (m *JsonMessage[T]) ID() []byte

func (*JsonMessage[T]) Metadata

func (m *JsonMessage[T]) Metadata() map[string]interface{}

func (*JsonMessage[T]) Pack

func (m *JsonMessage[T]) Pack() ([]byte, error)

func (*JsonMessage[T]) SetData

func (m *JsonMessage[T]) SetData(data T) error

func (*JsonMessage[T]) SetID

func (m *JsonMessage[T]) SetID(id []byte) error

func (*JsonMessage[T]) SetMetadata

func (m *JsonMessage[T]) SetMetadata(metadata map[string]interface{}) error

func (*JsonMessage[T]) String

func (m *JsonMessage[T]) String() string

func (*JsonMessage[T]) Unpack

func (m *JsonMessage[T]) Unpack(b []byte) error

type Message

type Message[T any] interface {
	ID() []byte
	SetID(id []byte) error

	// Used for recording extra data, e.g, retry count
	Metadata() map[string]interface{}
	SetMetadata(metadata map[string]interface{}) error

	Data() T
	SetData(data T) error

	// Converts the message into a binary package
	Pack() ([]byte, error)

	// Converts a binary package into the message
	Unpack([]byte) error

	String() string
}

Message represents a message that can be sent to a queue, network, etc NOTE: It's not thread-safe

type MessageIDGenerator

type MessageIDGenerator func() ([]byte, error)

func GenerateSequencialIDFunc

func GenerateSequencialIDFunc() MessageIDGenerator

Jump to

Keyboard shortcuts

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