go_rabbit

package module
v0.0.0-...-1cda25b Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2023 License: MIT Imports: 7 Imported by: 0

README

Installation

go get github.com/RuSS-B/go-rabbit

Example Usage

import (
	"fmt"
	rabbitmq "github.com/RuSS-B/go-rabbit"
)

conn, err := rabbitmq.NewConnection("amqp://guest:guest@127.0.0.1", rabbitmq.Config{ConnectionName: "listener", MaxAttempts: 10})
if err != nil {
	fmt.Println("Unable to connect.", err)
}
defer conn.Close()

//The methods inside callback will be executed after successful connection to MQ. 
conn.WhenConnected(func(conn *rabbitmq.Connection) {
    go handleS3()
    go handleMetrics()
})

<- conn.Closed

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ConnectionName string
	MaxAttempts    uint
}

type Connection

type Connection struct {
	Closed chan bool
	// contains filtered or unexported fields
}

func CreateNewAndConnect

func CreateNewAndConnect(serverURL string, cfg Config) (*Connection, error)

func NewConnection

func NewConnection(serverURL string, cfg Config) *Connection

func (*Connection) Close

func (conn *Connection) Close()

func (*Connection) Connect

func (conn *Connection) Connect() error

func (*Connection) WhenConnected

func (conn *Connection) WhenConnected(handler onSuccessConn) *Connection

type MessageHandler

type MessageHandler func(message amqp.Delivery)

type Queue

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

func NewQueue

func NewQueue(queueName string, conn *Connection) (Queue, error)

func (*Queue) Close

func (queue *Queue) Close()

func (*Queue) IsClosed

func (queue *Queue) IsClosed() bool

func (*Queue) Listen

func (queue *Queue) Listen(handler MessageHandler) error

func (*Queue) Publish

func (queue *Queue) Publish(body []byte) error

type TopicExchange

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

func NewTopicExchange

func NewTopicExchange(exchangeName string, queueName string, topics []string, conn *Connection) (TopicExchange, error)

func (*TopicExchange) Close

func (ex *TopicExchange) Close()

func (*TopicExchange) IsClosed

func (ex *TopicExchange) IsClosed() bool

func (*TopicExchange) Listen

func (ex *TopicExchange) Listen(handler MessageHandler) error

Jump to

Keyboard shortcuts

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