mq

package
v0.2.24 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	From  = contextx.From[tCtxPubSub, PubSub]
	Must  = contextx.Must[tCtxPubSub, PubSub]
	With  = contextx.With[tCtxPubSub, PubSub]
	Carry = contextx.Carry[tCtxPubSub, PubSub]
)

Functions

func CRC added in v0.2.24

func CRC(k string) uint16

func Fnv added in v0.2.24

func Fnv(k string) uint16

func MarshalV

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

func UnmarshalV

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

Types

type ConsumeMode added in v0.2.24

type ConsumeMode int
const (
	// GlobalOrdered messages are processed strictly one by one in the order
	// they were received globally.
	GlobalOrdered ConsumeMode = iota
	// PartitionOrdered messages with the same partition key are processed sequentially,
	// while messages with different keys are handled in parallel.
	PartitionOrdered
	// Concurrent messages are processed in parallel with no guarantee of ordering.
	// this mode offers the highest throughput.
	Concurrent
)

type Handler added in v0.2.24

type Handler func(context.Context, Message) error

type Hasher added in v0.2.24

type Hasher func(string) uint16

Hasher help to hash message.Key to dispatch message to task worker

type Message

type Message interface {
	Topic() string
	ID() int64
	Timestamp() time.Time

	Data() []byte
	Extra() map[string][]string
}

func NewMessage

func NewMessage(ctx context.Context, topic string, v any) Message

func NewMessageFromRaw

func NewMessageFromRaw(ctx context.Context, topic string, raw []byte) Message

func NewMessageWithID

func NewMessageWithID(topic string, id int64, v any) Message

func ParseMessage

func ParseMessage(data []byte) (Message, error)

ParseMessage data from message queue consumer

type MessageArshaler

type MessageArshaler interface {
	Marshal() ([]byte, error)
	Unmarshal([]byte) error
}

type MutMessage

type MutMessage interface {
	Message

	AddExtra(string, string)
	SetSubOrderedKey(string)
	SetPubOrderedKey(string)
}

type Option

type Option interface {
	OptionScheme() string
}

type OptionApplier

type OptionApplier interface {
	Apply(Option)
}

type OptionApplyFunc

type OptionApplyFunc func(Option)

func (OptionApplyFunc) Apply

func (f OptionApplyFunc) Apply(opt Option)

type OrderedMessage

type OrderedMessage interface {
	Message

	PubOrderedKey() string
	SubOrderedKey() string
}

type PubSub

type PubSub interface {
	// Publisher returns a publisher
	Publisher(ctx context.Context, options ...OptionApplier) (Publisher, error)
	// Subscriber returns a subscriber
	Subscriber(ctx context.Context, options ...OptionApplier) (Subscriber, error)
	// Close closes pub/sub endpoint
	Close() error
}

type Publisher

type Publisher interface {
	Topic() string
	Publish(context.Context, any) error
	PublishMessage(context.Context, Message) error
	Close()
}

type Subscriber

type Subscriber interface {
	// Run starts consuming and handling messages with h
	Run(ctx context.Context, h func(context.Context, Message) error) error
	// Close closes this subscriber
	Close()
}

Jump to

Keyboard shortcuts

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