contracts

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2025 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DistributedLocker

type DistributedLocker interface {
	CreateMutexLock(name string, lockOptions LockOptions) Lock
}

type HeartBeatFunc

type HeartBeatFunc func(ctx context.Context) error

type Lock

type Lock interface {
	TryLock() error
	Lock() error
	Unlock() (bool, error)
	Value() string
}

type LockOptions

type LockOptions struct {
	Expiry     time.Duration
	RetryDelay time.Duration
	Value      string
	Retries    int
}

type Message

type Message struct {
	ID      string
	Payload string
	// contains filtered or unexported fields
}

func NewMessage

func NewMessage(id, payload string, receiveCount int64) Message

func (Message) GetId

func (m Message) GetId() string

func (Message) GetPayload

func (m Message) GetPayload() string

func (Message) GetReceiveCount

func (m Message) GetReceiveCount() int64

type MessageQueue

type MessageQueue interface {
	Len() (int64, error)                                                                                                                                          // Returns the number of messages in the queue.
	Add(ctx context.Context, message *Message) error                                                                                                              // Adds a new message to the queue.
	Receive(ctx context.Context, pullDuration time.Duration, batchSize int, group, consumerName string) ([]Message, error)                                        // Receives messages from the queue.
	Consume(ctx context.Context, readBatchSize int, blockDuration time.Duration, group, consumerName string, errorChannel chan error, consumer StreamConsumeFunc) // Consumes messages using the provided consumer function.
	Delete(ctx context.Context, id string) error                                                                                                                  // Deletes a specific message from the queue.
	Purge(ctx context.Context) error                                                                                                                              // Clears all messages from the queue.
	Ack(ctx context.Context, group, messageId string) error                                                                                                       // Acknowledges the processing of a message.
	RequireHeartHeartBeat() bool                                                                                                                                  // Indicates if a heartbeat is required for message processing.
	HeartBeat(ctx context.Context, group, consumer, messageId string) error                                                                                       // Sends a heartbeat for a specific message.                                                                       // Sends a heartbeat for a specific message.
}

MessageQueue defines the contract for a message queue system. This interface provides methods for message management, including adding, receiving, consuming, and acknowledging messages.

type QueueError

type QueueError string
const ErrNoNewMessage QueueError = "no new message"
const MessageNotFoundError QueueError = "message not found"
const NotInitializedError QueueError = "you should initialize rmq first"

func (QueueError) Error

func (e QueueError) Error() string

type StreamConsumeFunc

type StreamConsumeFunc func(context.Context, Message, HeartBeatFunc) error

Jump to

Keyboard shortcuts

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