queue

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package queue provides asynchronous webhook delivery with worker pool.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	QueueSize    int
	WorkerCount  int
	BatchSize    int
	DrainTimeout time.Duration
}

Config holds configuration for the delivery queue.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a default queue configuration.

type DeliveryItem

type DeliveryItem struct {
	Webhook   *webhook.Webhook
	WebhookID string // The config ID for tracking
	EventID   string
}

DeliveryItem represents a webhook to be delivered.

type DeliveryQueue

type DeliveryQueue struct {
	// contains filtered or unexported fields
}

DeliveryQueue manages asynchronous webhook delivery with a worker pool.

func NewDeliveryQueue

func NewDeliveryQueue(
	client *webhook.Client,
	repo repository.WebhookRepository,
	cfg Config,
	opts ...Option,
) *DeliveryQueue

NewDeliveryQueue creates a new delivery queue with the specified configuration.

func (*DeliveryQueue) Enqueue

func (q *DeliveryQueue) Enqueue(item DeliveryItem) bool

Enqueue adds a webhook to the delivery queue. Returns false if the queue is full or stopped.

func (*DeliveryQueue) Pending

func (q *DeliveryQueue) Pending() int

Pending returns the number of items waiting in the queue.

func (*DeliveryQueue) Start

func (q *DeliveryQueue) Start(ctx context.Context)

Start begins processing webhooks from the queue.

func (*DeliveryQueue) Stop

func (q *DeliveryQueue) Stop()

Stop gracefully shuts down the queue, waiting for pending deliveries.

type Logger

type Logger interface {
	Info(msg string, args ...any)
	Error(msg string, args ...any)
	Debug(msg string, args ...any)
	Warn(msg string, args ...any)
}

Logger defines the logging interface for the queue.

type Option

type Option func(*DeliveryQueue)

Option configures the DeliveryQueue.

func WithLogger

func WithLogger(logger Logger) Option

WithLogger sets the logger for the queue.

Jump to

Keyboard shortcuts

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