rabbitmq

package module
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2023 License: MIT Imports: 7 Imported by: 3

README

go-rabbitmq

An slightly opiniated abstraction for using RabbitMQ services from various Cloud environments. Only tested on Cloudfoundry at this time.

usage

consumer

producer

integration test

docker-compose -f docker/docker-compose.test.yml up --build --abort-on-container-exit

author

Andy Lo-A-Foe andy.loafoe@aemian.com

license

MIT

Documentation

Overview

Copyright 2018 Andy Lo-A-Foe. All rights reserved. Use of this source code is governed by Apache-style license that can be found in the LICENSE file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AMQPConsumer added in v0.3.0

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

func NewConsumer

func NewConsumer(config Config) (*AMQPConsumer, error)

func (*AMQPConsumer) Connect added in v0.3.0

func (c *AMQPConsumer) Connect() error

Connect to RabbitMQ server

func (*AMQPConsumer) Handle added in v0.3.0

func (c *AMQPConsumer) Handle(
	d <-chan amqp.Delivery,
	fn ConsumerHandlerFunc,
	threads int,
	queue string,
	routingKey string)

Handle has all the logic to make sure your program keeps running d should be a delievey channel as created when you call announceQueue fn should be a function that handles the processing of deliveries this should be the last thing called in main as code under it will become unreachable unless put int a goroutine. The q and rk params are redundent but allow you to have multiple queue listeners in main without them you would be tied into only using one queue per connection

func (*AMQPConsumer) Start added in v0.3.0

func (c *AMQPConsumer) Start() error

type AMQPProducer added in v0.3.0

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

func NewProducer

func NewProducer(config Config) (*AMQPProducer, error)

func (*AMQPProducer) Close added in v0.3.0

func (p *AMQPProducer) Close()

func (*AMQPProducer) Publish added in v0.3.0

func (p *AMQPProducer) Publish(exchange, routingKey string, msg amqp.Publishing) error

type Config

type Config struct {
	ServiceName  string
	Exchange     string
	ExchangeType string
	Durable      bool
	AutoDelete   bool
	QueueName    string
	RoutingKey   string
	CTag         string
	Qos          *Qos
	HandlerFunc  ConsumerHandlerFunc
}

type Consumer

type Consumer interface {
	Connect() error
	Start() error
	Handle(d <-chan amqp.Delivery, f ConsumerHandlerFunc, threads int, queue string, routingKey string)
}

type ConsumerHandlerFunc

type ConsumerHandlerFunc func(deliveries <-chan amqp.Delivery, done <-chan bool)

type Producer

type Producer interface {
	Publish(exchange, routingKey string, msg amqp.Publishing) error
	Close()
}

type Qos added in v0.6.0

type Qos struct {
	PrefetchCount int
	PrefetchSize  int
	Global        bool
}

Jump to

Keyboard shortcuts

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