• Stars
    star
    132
  • Rank 274,205 (Top 6 %)
  • Language
    Go
  • License
    MIT License
  • Created over 11 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Golang framework for simple message passing using an AMQP broker

relay

Relay is a Go framework for task queues, and makes writing code for publishers and consumers very simple. It is a wrapper around the AMQP protocol, and relies on a message broker like RabbitMQ.

The reason Relay exists is that AMQP is a tedious protocol to deal with, and the high level abstraction of a task queue is often something that is desirable. With Relay, you simply Publish objects into task queues, and Consume them on the other end.

Features

  • Simple to use, hides the AMQP details
  • Flexible encoding and decoding support
  • Configuration changes instead of code changes

Documentation

See the online documentation here: http://godoc.org/github.com/armon/relay.

Example

Here is an example of a simple publisher:

conf := &relay.Config{Addr: "rabbitmq"}
conn, err := relay.New(conf)
defer conn.Close()

pub, err := conn.Publisher("tasks")
defer pub.Close()

pub.Publish("this is a test message")

Here is an example of a simple consumer:

conf := &relay.Config{Addr: "rabbitmq"}
conn, err := relay.New(conf)
defer conn.Close()

cons, err := conn.Consumer("tasks")
defer cons.Close()

var msg string
for {
    cons.ConsumeAck(&msg)
    fmt.Printf("Got msg: %s\n", msg)
}

Here is an example of a consumer using prefetching and multi Acks:

conf := &relay.Config{Addr: "rabbitmq", PrefetchCount: 5, EnableMultiAck: true}
conn, err := relay.New(conf)
defer conn.Close()

cons, err := conn.Consumer("tasks")
defer cons.Close()

var msg string
for {
    // Consume 5 messages
    for i := 0; i < 5; i++ {
        cons.Consume(&msg)
        fmt.Printf("Got msg: %s\n", msg)
    }

    // Acks the last 5 messages
    cons.Ack()
}

More Repositories

1

go-socks5

SOCKS5 server in Golang
Go
1,933
star
2

bloomd

C network daemon for bloom filters
C
1,237
star
3

go-radix

Golang implementation of Radix trees
Go
883
star
4

libart

Adaptive Radix Trees implemented in C
C
765
star
5

hlld

C network daemon for HyperLogLogs
C
449
star
6

go-proxyproto

Golang package to handle HAProxy Proxy Protocol
Go
199
star
7

circbuf

Golang circular (ring) buffer
Go
171
star
8

go-chord

Golang implementation of the Chord protocol
Go
132
star
9

consul-api

Golang API client for Consul
Go
123
star
10

pypred

A Python library for simple evaluation of natural language predicates
Python
61
star
11

erl-rstar

An Erlang implementation of the R*-tree spacial data structure
Erlang
59
star
12

c-minheap-array

Implements a Min-Heap / Priority Queue in C using a simple array.
C
56
star
13

counterd

A lightweight daemon for counting unique events using Redis and PostgreSQL
Go
35
star
14

consul-kv

Golang K/V client for Consul
Go
33
star
15

DjangoProjectExample

An example Django project
Python
28
star
16

c-minheap-indirect

Implements a Min-Heap / Priority Queue in C using an indirection table for memory efficiency.
C
28
star
17

cse473-ai-csp

A Constraint Satisfaction Solver (CSP) using Backtracking and Forward Checking
Java
23
star
18

go-hlld

Golang client for HyperLogLog daemon (hlld)
Go
21
star
19

cuda-hll

A CUDA accelerated utility for using HyperLogLog's for cardinality estimation
18
star
20

teles

An Erlang network service for manipulating geographic data
Erlang
15
star
21

bloomd_ring

Provides a Riak core interface to bloomd to allow for horizontal scalability and high availability
Erlang
14
star
22

Erlang-Naive-Bayes-Movies

An Erlang naive bayes text classifier to classify movie reviews as positive or negative.
Erlang
13
star
23

pyhlld

A Python driver for the hlld server
Python
10
star
24

ememcached

An Erlang Implementation of the Memcached binary protocol
Erlang
9
star
25

erl-bloomd

An Erlang driver for speaking the Bloomd network protocol
Erlang
8
star
26

DotFiles

Misc. dot files
Vim Script
3
star
27

pyteles

A Python client for the Teles server
Python
1
star