gorabbitmq

package module
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: May 18, 2021 License: MIT Imports: 6 Imported by: 0

README

MrAndreID / Go RabbitMQ

Go Reference

The MrAndreID/GoRabbitMQ package is a collection of functions in the go language for RabbitMQ.


Table of Contents


Install

To use The MrAndreID/GoRabbitMQ package, you must follow the steps below:

go get -u github.com/MrAndreID/gorabbitmq

Usage

Client
import "github.com/MrAndreID/gohelpers"

err := gorabbitmq.Client("Andrea Adam", gorabbitmq.Connection{"127.0.0.1", "5672", "account", "account", "account"}, gorabbitmq.QueueSetting{"account", true, false, false, false, nil}, gorabbitmq.OtherSetting{"account", "60000", false, false, 18})

if err != nil {
    gohelpers.HandleResponse(response, 400, "looks like something went wrong", err)

    return
}
Server
import "services/controllers"

gorabbitmq.Server(gorabbitmq.Connection{"127.0.0.1", "5672", "account", "account", "account"}, gorabbitmq.QueueSetting{"account", true, false, false, false, nil}, gorabbitmq.ConsumeSetting{"", false, false, false, false, nil}, gorabbitmq.OtherSetting{"account", "60000", false, false, 18}, controllers.HandleRequest)
RPC Client
import "github.com/MrAndreID/gohelpers"

result, err := gorabbitmq.RPCClient("Andrea Adam", gorabbitmq.Connection{"127.0.0.1", "5672", "account", "account", "account"}, gorabbitmq.QueueSetting{"account", true, false, false, false, nil}, gorabbitmq.ConsumeSetting{"", true, false, false, false, nil}, gorabbitmq.OtherSetting{"account", "60000", false, false, 18})

if err != nil {
    gohelpers.HandleResponse(response, 400, "looks like something went wrong", err)

    return
}
RPC Server
import "services/routes"

gorabbitmq.RPCServer(gorabbitmq.Connection{"127.0.0.1", "5672", "account", "account", "account"}, gorabbitmq.QueueSetting{"account", true, false, false, false, nil}, gorabbitmq.QosSetting{1, 0, false}, gorabbitmq.ConsumeSetting{"", false, false, false, false, nil}, gorabbitmq.OtherSetting{"account", "60000", false, false, 18}, routes.HandleRequest)

Versioning

I use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

Andrea Adam - MrAndreID

License

MIT licensed. See the LICENSE file for details.

Official Documentation for Go Language

Documentation for Go Language can be found on the Go Language website.

More

Documentation can be found on https://go.dev/.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Client added in v1.2.0

func Client(body string, connection Connection, queueSetting QueueSetting, otherSetting OtherSetting) (errorResponse error)

func RPCClient

func RPCClient(body string, connection Connection, queueSetting QueueSetting, consumeSetting ConsumeSetting, otherSetting OtherSetting) (response string, errorResponse error)

func RPCServer added in v1.1.0

func RPCServer(connection Connection, queueSetting QueueSetting, qosSetting QosSetting, consumeSetting ConsumeSetting, otherSetting OtherSetting, routeFunc RouteFunc)

func Server added in v1.3.0

func Server(connection Connection, queueSetting QueueSetting, consumeSetting ConsumeSetting, actionFunc ActionFunc)

Types

type AMQPChannel added in v1.1.1

type AMQPChannel struct {
	*amqp.Channel
	// contains filtered or unexported fields
}

func (*AMQPChannel) Close added in v1.1.1

func (channel *AMQPChannel) Close() error

func (*AMQPChannel) Consume added in v1.1.1

func (channel *AMQPChannel) Consume(queue, consumer string, autoAck, exclusive, noLocal, noWait bool, args amqp.Table) (<-chan amqp.Delivery, error)

func (*AMQPChannel) IsClosed added in v1.1.1

func (channel *AMQPChannel) IsClosed() bool

type AMQPConnection added in v1.1.1

type AMQPConnection struct {
	*amqp.Connection
}

func Dial added in v1.1.1

func Dial(url string) (*AMQPConnection, error)

func (*AMQPConnection) Channel added in v1.1.1

func (connection *AMQPConnection) Channel() (*AMQPChannel, error)

type ActionFunc added in v1.3.1

type ActionFunc func(string)

type Connection

type Connection struct {
	Host, Port, Username, Password, VirtualHost string
}

type ConsumeSetting

type ConsumeSetting struct {
	Consumer                            string
	AutoAck, Exclusive, NoLocal, NoWait bool
	Args                                map[string]interface{}
}

type OtherSetting

type OtherSetting struct {
	RoutingKey, Expiration string
	Mandatory, Immediate   bool
	Timeout                time.Duration
}

type QosSetting added in v1.1.0

type QosSetting struct {
	PrefetchCount, PrefetchSize int
	Global                      bool
}

type QueueSetting

type QueueSetting struct {
	Name                                   string
	Durable, AutoDelete, Exclusive, NoWait bool
	Args                                   map[string]interface{}
}

type RouteFunc added in v1.1.0

type RouteFunc func(string) string

Jump to

Keyboard shortcuts

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