rmqclient

package module
v0.0.0-...-7d7e8ba Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2019 License: MIT Imports: 12 Imported by: 0

README

rmqclient_
----------

.. All external links are here
.. _rmqclient: https://github.com/vsdmars/rmqclient
.. |go report| image:: https://goreportcard.com/badge/github.com/vsdmars/rmqclient
  :target: https://goreportcard.com/report/github.com/vsdmars/rmqclient
.. |go doc| image:: https://godoc.org/github.com/vsdmars/rmqclient?status.svg
  :target: https://godoc.org/github.com/vsdmars/rmqclient
.. |license| image:: https://img.shields.io/github/license/mashape/apistatus.svg?style=flat
  :target: ./LICENSE
.. _example: ./example/cmd.go

.. ;; And now we continue with the actual content

|go report| |go doc| |license|

----

rmqclient library provides robust client connection to rabbitmq cluster.

----


=====
Usage
=====

Example
-------

Refer to example_


Contact
-------
Bug, feature requests, welcome to shoot me an email at:

**vsdmars<at>gmail.com**

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetLogLevel

func SetLogLevel(level zapcore.Level)

SetLogLevel sets the rmqclient log level

noop if caller provides it's own zap logger

func SetLogger

func SetLogger(l *zap.Logger)

SetLogger sets caller provided zap logger

reset to rmqclient's logger by passing in nil pointer

func Sync

func Sync()

Sync sync logger output

Types

type ConsumeHandle

type ConsumeHandle func(context.Context, <-chan amqp.Delivery) error

ConsumeHandle consumer callback handle's signature

Handle should honor passing-in context for cleanup

type Publish

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

Publish is the publish interface for client https://godoc.org/github.com/streadway/amqp#Channel.Publish https://godoc.org/github.com/streadway/amqp#Channel.NotifyReturn https://godoc.org/github.com/streadway/amqp#Channel.NotifyPublish https://godoc.org/github.com/streadway/amqp#Channel.NotifyConfirm

func (*Publish) Close

func (p *Publish) Close()

Close closes publish channel.

func (*Publish) Confirm

func (p *Publish) Confirm() bool

Confirm returns current publish's confirm mode.

func (*Publish) Publish

func (p *Publish) Publish(
	exchange, key string, mandatory, immediate bool, msg amqp.Publishing) error

Publish send message to the rabbitmq server.

type RmqConfig

type RmqConfig struct {
	Username      string        `validate:"required"`
	Password      string        `validate:"required"`
	Host          string        `validate:"required"`
	Vhost         string        `validate:"required"`
	Port          int           `validate:"required"`
	ReconnectWait time.Duration `validate:"isdefault"`
}

RmqConfig is the config type for rmqclient

type RmqStruct

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

RmqStruct is the instance of rabbitmq service

func NewRmq

func NewRmq(ctx context.Context, cfg RmqConfig) (*RmqStruct, error)

NewRmq creates new rabbitmq connection instance

func (*RmqStruct) GetPublish

func (rmq *RmqStruct) GetPublish(confirm bool) (*Publish, error)

GetPublish retrieve publish from pool

func (*RmqStruct) RegisterHandle

func (rmq *RmqStruct) RegisterHandle(
	name string,
	h ConsumeHandle,
	autoAck bool,
	exclusive bool,
	noWait bool,
) (err error)

RegisterHandle register consumer's handle

func (*RmqStruct) Run

func (rmq *RmqStruct) Run()

Run starts rabbitmq service

Non-block call

Runs as daemon, exit on caller's context cancel()

func (*RmqStruct) UnregisterHandle

func (rmq *RmqStruct) UnregisterHandle(name string) (err error)

UnregisterHandle unregister consumer's handle

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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