conejo

package module
v0.0.0-...-9cfc187 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2018 License: MIT Imports: 2 Imported by: 2

README

Conejo Go Report Card GoDoc Sourcegraph

Golang lib for RabbitMQ Connecting, Consuming, and Publishing. Needs a great deal of refining, but it's quick & dirty and gets the job done for my current project. WIll definitely refactor in the near future.

Status

Currently on hold. I use this lib for several personal projects so all should be working as intended.

Goals

  • Unit Tests
    • main.go
    • channel.go
    • producer.go
    • queue.go
    • exchange.go

Usage

Sample Producer
package main

import (
  "github.com/josemrobles/conejo"
)

var (
  rmq      = conejo.Connect("amqp://guest:guest@localhost:5672")
  workQueue = make(chan string) 
  queue    = conejo.Queue{Name: "queue_name", Durable: false, Delete: false, Exclusive: false, NoWait: false}
  exchange = conejo.Exchange{Name: "exchange_name", Type: "topic", Durable: true, AutoDeleted: false, Internal: false, NoWait: false}
)

func main() {
  err := conejo.Publish(rmq, queue, exchange, "{'employees':[{'firstName':'John','lastName':'Doe'}]}")
  if err != nil {
    print("fubar")
  }
}
Sample Consumer
package main

import (
  "github.com/josemrobles/conejo"
)

var (
  rmq       = conejo.Connect("amqp://guest:guest@localhost:5672")
  queue     = conejo.Queue{Name: "queue_name", Durable: false, Delete: false, Exclusive: false, NoWait: false}
  exchange  = conejo.Exchange{Name: "exchange_name", Type: "topic", Durable: true, AutoDeleted: false, Internal: false, NoWait: false}
  
)

func main() {
  err := conejo.Consume(rmq, queue, exchange, "consumer_tag", workQueue)
  if err != nil {
    print("ERROR: %q", err)
  }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseChannel

func CloseChannel(channel *amqp.Channel)

func Connect

func Connect(amqpURI string) *amqp.Connection

Connect to the RabbitMQ Sever using the server URI [string]. If a connections is established, return the connection amqp.Connection.

func Consume

func Consume(conn *amqp.Connection, queue Queue, exchange Exchange, consumerTag string, cb chan string) error

func Publish

func Publish(conn *amqp.Connection, queue Queue, exchange Exchange, body string) error

Types

type Exchange

type Exchange struct {
	Name        string
	Type        string
	Durable     bool
	AutoDeleted bool
	Internal    bool
	NoWait      bool
	Arguments   amqp.Table
}

type Queue

type Queue struct {
	Name      string
	Durable   bool
	Delete    bool
	Exclusive bool
	NoWait    bool
	Arguments amqp.Table
}

Jump to

Keyboard shortcuts

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