queue

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Code generated by interfacer, DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CallbackFunc

type CallbackFunc func(ctx context.Context, events []Event) []int

CallbackFunc is a function that is called when a message is received This will not be called when there are no messages to process It receives a context and a slice of events, and returns a slice of integers representing the indices of the events that were successfully processed.

type ConsumerConfig

type ConsumerConfig struct {
	ConsumerName    string         // The name for the consumer
	Topic           string         // The topic to listen on, e.g: events.books
	FetchLimit      int            // The maximum number of messages to fetch per second
	Callback        CallbackFunc   // The callback function to process messages
	CallbackTimeout *time.Duration // Optional timeout for the callback function, defaults to 1 minute
	Wait            *time.Duration // Optional wait time for the consumer before fetching messages, defaults to 1 second
}

Configuration for a consumer.

type Event

type Event struct {
	Index   int    // the index of the event in the batch
	Payload []byte // the data of the event
}

type Queue

type Queue interface {
	// Runs a consumer by given configuration and callback function
	// OBS: This function is blocking, so make sure to run it in a goroutine if
	// you want to run other code in parallel.
	// Returns an error if the consumer could not be created or updated.
	Consume(config ConsumerConfig) error
	// Publishes a message to the specified topic.
	// The function accepts a variadic parameter for timeout duration, defaulting to 5 seconds if not provided.
	Publish(topic string, message []byte, timeout ...time.Duration) error
}

Queue defines the public interface for queue.

func NewQueue added in v1.1.5

func NewQueue(params config.QueueConfig) (Queue, error)

Initializes a new Queue.

Jump to

Keyboard shortcuts

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