Skip to content

Repository files navigation

Queue

Go Version License GoDoc Go Report Card codecov Release

Queue is a Go library that gives Hub pipeline and workflow services one API for publishing, consuming, routing, retrying, and dead-lettering messages across different message brokers.

Supported Brokers

Broker Implementation Guide
RabbitMQ amqp091-go RabbitMQ guide
Kafka Confluent Kafka Go client Kafka guide
Azure Event Hubs Kafka-compatible endpoint Event Hubs guide
Amazon SQS AWS SDK for Go v2 SQS guide

The broker guides contain provider-specific setup, configuration, security, delivery semantics, examples, and troubleshooting notes.

Installation

go get github.com/uug-ai/queue

Core Abstractions

Options

Each broker exposes a typed options builder that implements QueueOptions. Options are validated when the client is created.

Client

New(options) selects the broker from the concrete options type and returns a Queue containing the validated options and a QueueInterface client.

func connect(options queue.QueueOptions) (*queue.Queue, error) {
    client, err := queue.New(options)
    if err != nil {
        return nil, err
    }
    if err := client.Client.Connect(); err != nil {
        return nil, err
    }
    return client, nil
}

Call Close when the client is no longer needed.

Common Operations

QueueInterface provides the shared broker lifecycle and messaging operations:

  • Connect, Reconnect, and Close
  • Publish and PublishWithDelay
  • ReadMessages and RouteMessages
  • AddToDeadletter and DisasterRecovery
  • SetDisasterRecoveryHandler
  • LoadMessages

Pipeline Actions

Message handlers return a models.PipelineAction. The queue client maps that action to broker operations:

Action Result
PipelineForward Advance and publish the event to the configured router
PipelineCancel Complete the message without forwarding
PipelineRetry Republish with a bounded retry count
PipelineError Publish to the configured dead-letter destination

All providers implement at-least-once processing. Handlers and downstream writes should therefore be idempotent.

Choosing a Broker

Use the broker-specific builder and follow its guide:

Application code can depend on QueueInterface after construction, keeping most processing logic independent of the selected broker.

Testing

Run the complete test suite:

go test ./...

Verify the non-CGO build used by RabbitMQ-only applications:

CGO_ENABLED=0 go test ./...

Contributing

New providers should implement QueueInterface, expose a typed options builder, validate required configuration, and include broker-free unit tests for publish, consume, retry, and dead-letter behavior.

License

This project is licensed under the MIT License. See LICENSE.

Support

About

A Go library that implements a set of event and message brokers through a single library

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

Generated from uug-ai/templates-go