istra

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

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

Go to latest
Published: Jan 21, 2020 License: MIT Imports: 2 Imported by: 0

README

Build Status Coverage Status Go Report Card GoDoc MIT licensed

Go AMQP wrapper

This is an AMQP Library wrapper.

Example


import (
	"github.com/shuvis/istra"
	"github.com/streadway/amqp"
)

func main() {
	conn, err := amqp.Dial("amqp://guest:guest@localhost:5672/")
	if err != nil {
		panic(err)
	}

	err = istra.Process(conn,
		istra.ExchangeDeclare{Exchange: "testExchange", Kind: "fanout", Durable: true},
		istra.QueueDeclare{Name: "testQueue", Durable: true, AutoDelete: true},
		istra.Bind{Queue: "testQueue", Exchange: "testExchange", Topic: "topic"})

	if err != nil {
		panic(err)
	}

	go istra.ConsumeQueue(conn, istra.QueueConf{Name: "testQueue"}, func(d amqp.Delivery) {
		// process delivery
	})

	err = istra.Process(conn,
		istra.UnBind{Queue: "testQueue", Exchange: "testExchange", Topic: "topic"})

	if err != nil {
		panic(err)
	}
}

License

MIT License - see LICENSE for more details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConsumeQueue

func ConsumeQueue(conn *amqp.Connection, conf QueueConf, f func(amqp.Delivery))

ConsumeQueue calls handler function on each message delivered to a queue. This is blocking operation.

func Process

func Process(conn *amqp.Connection, actions ...action) error

Process executes actions in order they passed. Non-blocking operation.

Types

type Bind

type Bind struct {
	Queue    string
	Exchange string
	Topic    string
	NoWait   bool
}

Bind action which binds Queue to Exchange

type ExchangeDeclare

type ExchangeDeclare struct {
	Exchange   string
	Kind       string
	Durable    bool
	AutoDelete bool
	Internal   bool
	NoWait     bool
}

ExchangeDeclare action which creates new exchange

type QueueConf

type QueueConf struct {
	Name          string
	AutoAck       bool
	Exclusive     bool
	NoLocal       bool
	NoWait        bool
	PrefetchSize  int
	PrefetchCount int
	Global        bool
}

QueueDeclare configuration for consuming queue with ConsumeQueue() method

type QueueDeclare

type QueueDeclare struct {
	Name       string
	Durable    bool
	AutoDelete bool
	Exclusive  bool
	NoWait     bool
}

QueueDeclare action which creates new queue

type UnBind

type UnBind struct {
	Exchange string
	Queue    string
	Topic    string
}

UnBind action which unbinds Queue from Exchange

Jump to

Keyboard shortcuts

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