limqa

package module
v0.0.0-...-fd6823a Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2021 License: MIT Imports: 2 Imported by: 0

README

LiMQA

abstraction for AMQP
a Go library that makes easier to AMQP communication

Table of Contents

About

Limqa is an client abstraction for AMQP communication using Consumer and Producer design. Limqa is built top of streadway/amqp.

Installation

You can install using go get

go get github.com/ahmetcanozcan/limqa

Usage

Hello World

package main

import (
 "fmt"

 "github.com/ahmetcanozcan/limqa"
)


func main() {
 uri := "amqp://guest:guest@localhost:5672"
 base := limqa.New()

 base.Connect(uri)

 consumer, _ := limqa.NewConsumer(base,"_queue","_exchange",limqa.DeclareExchange(true))
 // If you are sure that exchange is declared before
 // you don't have to declare it again.
 // consumer can be instantiated without DeclareExchange flag:
 // consumer, _ := limqa.NewConsumer(base,"_queue","_exchange")

 producer, _ := limqa.NewProducer(base,"_exchange")

 // Produce a message
 producer.Produce([]byte("Hello World"))

 // Get message from the consumer
 msg := consumer.Consume()

 fmt.Println(string(msg))
 // Output : Hello World
}

Options

a consumer or producer can be configured using limqa options

// ...
consumer1, _ := limqa.NewConsumer(base,"_queue","_exchange",limqa.DeclareExchange(true),limqa.NoAck(false))
// ...
consumer2, _ := limqa.NewConsumer(base,"_queue2","_exchange",limqa.NoWait(true),limqa.NoAck(true),limqa.NoLocal(true))

producer, _  := limqa.NewProducer(base,"_exchange",limqa.Durable(true),limqa.AutoDelete(false))
// ...

CLI

Limqa can be used by cli for message producing or consuming using Limqa library. It can be installed using go get

go get github.com/ahmetcanozcan/limqa/limqa

Now, we can produce and consume messages.

limqa produce -m "Hello World" -exchange hello_world
# Output : message sent
limqa consume -queue helo_queue_1 -e hello_world
# Output : Hello World

for more help for flags and commands use:

limqa -help

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Ahmetcan ÖZCAN - email

Documentation

Overview

Package limqa implements a

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNilBase :
	ErrNilBase = errors.New("Can not use <nil> in base")
	// ErrBaseNotConnected :
	ErrBaseNotConnected = errors.New("Base not connected")
)

Functions

This section is empty.

Types

type Base

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

Base :

func New

func New() *Base

New :

func (*Base) Connect

func (b *Base) Connect(uri string) error

Connect :

func (*Base) IsConnected

func (b *Base) IsConnected() bool

IsConnected :

type Consumer

type Consumer interface {
	Consume() []byte
}

Consumer :

func NewConsumer

func NewConsumer(base *Base, queue, exchange string, options ...Option) (Consumer, error)

NewConsumer :

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option :

func AutoAck

func AutoAck(f bool) Option

AutoAck :

func AutoDelete

func AutoDelete(f bool) Option

AutoDelete :

func DeclareExchange

func DeclareExchange(f bool) Option

DeclareExchange :

func Durable

func Durable(f bool) Option

Durable :

func Exclusive

func Exclusive(f bool) Option

Exclusive :

func Internal

func Internal(f bool) Option

Internal :

func NoLocal

func NoLocal(f bool) Option

NoLocal :

func NoWait

func NoWait(f bool) Option

NoWait :

type Producer

type Producer interface {
	Produce(data []byte) error
}

Producer :

func NewProducer

func NewProducer(base *Base, name string, options ...Option) (Producer, error)

NewProducer :

Directories

Path Synopsis
_examples
cmd

Jump to

Keyboard shortcuts

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