codec

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal(v any) ([]byte, error)

func SendMessage

func SendMessage(ctx context.Context, conn net.Conn, msg *Message) error

func SetMarshaller

func SetMarshaller(marshaller MarshallerFunc)

func SetUnmarshaller

func SetUnmarshaller(unmarshaller UnmarshallerFunc)

func Unmarshal

func Unmarshal(data []byte, v any) error

Types

type MarshallerFunc

type MarshallerFunc func(v any) ([]byte, error)

func (MarshallerFunc) Marshal

func (f MarshallerFunc) Marshal(v any) ([]byte, error)

type Message

type Message struct {
	Headers map[string]string `msgpack:"h"`
	Queue   string            `msgpack:"q"`
	Payload []byte            `msgpack:"p"`
	Command consts.CMD        `msgpack:"c"`
}

func Deserialize

func Deserialize(data []byte) (*Message, error)

func NewMessage

func NewMessage(cmd consts.CMD, payload []byte, queue string, headers map[string]string) *Message

func ReadMessage

func ReadMessage(ctx context.Context, conn net.Conn) (*Message, error)

func (*Message) Serialize

func (m *Message) Serialize() ([]byte, error)

type UnmarshallerFunc

type UnmarshallerFunc func(data []byte, v any) error

func (UnmarshallerFunc) Unmarshal

func (f UnmarshallerFunc) Unmarshal(data []byte, v any) error

Jump to

Keyboard shortcuts

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