Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AsyncConsumer ¶
type AsyncConsumer interface {
Consumer
// Start starts asynchronous message consumption with a handler
Start(handler MessageHandler, opts ConsumerOptions) error
// Stop stops asynchronous message consumption
Stop() error
}
AsyncConsumer interface for asynchronous message consumption
func NewAsyncConsumer ¶
func NewAsyncConsumer(id string, manager *queue.Manager, opts ...ClientOption) (AsyncConsumer, error)
NewAsyncConsumer creates a new asynchronous consumer
type Client ¶
type Client interface {
Producer
Consumer
// ID returns the client identifier
ID() string
// Close closes the client connection
Close() error
}
Client interface combines Producer and Consumer
type ClientOption ¶
type ClientOption func(*clientConfig)
ClientOption is a function that configures a client
func WithMetadata ¶
func WithMetadata(key, value string) ClientOption
WithMetadata adds metadata to the client
type ConnectionInfo ¶
type ConnectionInfo struct {
ClientID string
Subscriptions []string
LastActivity string
Metadata map[string]string
}
ConnectionInfo provides information about a client connection
type Consumer ¶
type Consumer interface {
// Subscribe subscribes to one or more topics
Subscribe(ctx context.Context, topics ...string) error
// Unsubscribe unsubscribes from one or more topics
Unsubscribe(ctx context.Context, topics ...string) error
// Receive receives messages (blocking with timeout)
Receive(ctx context.Context, limit int) ([]*types.Message, error)
// Ack acknowledges successful message processing
Ack(ctx context.Context, messageID string) error
// Nack acknowledges failed message processing
Nack(ctx context.Context, messageID string, reason string) error
}
Consumer interface for receiving messages
type ConsumerOptions ¶
type ConsumerOptions struct {
// MaxConcurrency limits concurrent message processing
MaxConcurrency int
// PollInterval sets how often to poll for messages
PollInterval int
// BatchSize sets how many messages to fetch at once
BatchSize int
// AutoAck automatically acknowledges messages after handler returns nil
AutoAck bool
}
ConsumerOptions configure a consumer
type MessageHandler ¶
MessageHandler is a callback for handling messages
type MessageOption ¶
MessageOption is a function that modifies message properties
func WithMaxRetries ¶
func WithMaxRetries(maxRetries int) MessageOption
WithMaxRetries sets the maximum retry count
func WithMessageMetadata ¶
func WithMessageMetadata(key, value string) MessageOption
WithMessageMetadata adds metadata to the message
func WithPriority ¶
func WithPriority(priority int) MessageOption
WithPriority sets the message priority
type Producer ¶
type Producer interface {
// SubmitTask submits a task to a topic
SubmitTask(ctx context.Context, topic string, payload []byte, opts ...MessageOption) (*types.Message, error)
// SendDirect sends a direct message to another client
SendDirect(ctx context.Context, to string, payload []byte, opts ...MessageOption) (*types.Message, error)
}
Producer interface for sending messages