Categorygithub.com/go-mq/mq/v2
modulepackage
2.0.2
Repository: https://github.com/go-mq/mq.git
Documentation: pkg.go.dev

# README

mq GoDoc Go Go Report Card

MQ is a generic interface to abstract the details of implementation of messaging queues systems.

Similar to the package database/sql, this package implements a common interface to interact with different message queue systems, in a unified way.

Installation

The recommended way to install mq is:

go get github.com/go-mq/mq/v2

Usage

This example shows how to publish and consume a Job from the in-memory implementation, very useful for unit tests.

The mq implementations to be supported by the NewBroker should be imported as shows the example.

package main

import (
    "fmt"
    "github.com/go-mq/mq/v2"
    _ "github.com/go-mq/mq/v2/memory"
    "log"
)

//...
func main() {
    b, _ := mq.NewBroker("memory://")
    q, _ := b.Queue("test-queue")
    j := mq.NewJob()
    
    if err := q.Publish(j); err != nil {
        log.Fatal(err)
    }
    
    iter, err := q.Consume(1)
    if err != nil {
        log.Fatal(err)
    }
    
    consumedJob, _ := iter.Next()
    
    var payload string
    _ = consumedJob.Decode(&payload)
    
    fmt.Println(payload)
    // Output: hello world!
}

License

Apache License Version 2.0, see LICENSE

# Packages

No description provided by the author
No description provided by the author

# Functions

NewBroker creates a new Broker based on the given URI.
NewJob creates a new Job with default values, a new unique ID and current timestamp.
Register registers a new BrokerBuilder to be used by NewBroker, this function should be used in an init function in the implementation packages such as `amqp` and `memory`.

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
PriorityLow represents a low priority level.
PriorityNormal represents a normal priority level.
PriorityUrgent represents an urgent priority level.

# Variables

ErrAlreadyClosed is the error returned when trying to close an already closed connection.
ErrCantAck is the error returned when the Job does not come from a queue.
ErrEmptyJob is the error returned when an empty job is published.
ErrMalformedURI is the error returned when a Broker does not know how to parse a given URI.
ErrTxNotSupported is the error returned when the transaction receives a callback does not know how to handle.
ErrUnsupportedProtocol is the error returned when a Broker does not know how to connect to a given URI.

# Structs

Job contains the information for a job to be published to a queue.

# Interfaces

Acknowledger represents the object in charge of acknowledgement management for a job.
Broker represents a message broker.
JobIter represents an iterator over a set of Jobs.
No description provided by the author
Queue represents a message queue.
No description provided by the author

# Type aliases

BrokerBuilder instantiates a new Broker based on the given uri.
Priority represents a priority level.
RepublishConditionFunc is a function used to filter jobs to republish.
RepublishConditions alias of a list RepublishConditionFunc.
TxCallback is a function to be called in a transaction.