• Stars
    star
    274
  • Rank 150,274 (Top 3 %)
  • Language
    Go
  • License
    MIT License
  • Created about 8 years ago
  • Updated about 8 years ago

Reviews

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

Repository Details

📥 IMAP based message broker client

IMAPMQ is an IMAP based message broker client. It provides a simple interface for publishing, subscribing and dequeuing messages. It also supports concurrent access to the same message queue. Based on go-imap.

Go Report Card GoDoc

How it works

IMAPMQ treats IMAP mailboxes as queues. In order to add a message to a queue, IMAPMQ appends an email to the mailbox.

Features

  • IMAPMQ can connect to any IMAPv4rev1 server with the CONDSTORE extension
  • Publish/Subscribe
  • Message Queue
  • Message format agnostic
  • No polling, the IMAP server notifies the client of new messages thanks to the IDLE command
  • Concurrency aware: multiple dequeuing instances can work on the same queue
  • Bring your own GUI: any IMAP client would do

Installing

$ go get github.com/mikaa123/imapmq

Example: A simple chat

The following example connects to an IMAP account, and creates a queue based on the INBOX mailbox. It spawns a goroutine that subscribes to the "chat" topic and listens to the returned channel. Anytime a user writes something and press enter, a new "chat" message is published to the queue.

You need to have an IMAP server to connect to. If you don't, you can create a gmail account. Make sure you enable IMAP (more info here) if you do.

package main

import (
	"bufio"
	"log"
	"os"

	"github.com/mikaa123/imapmq"
)

func main() {
	// Create a new IMAPMQ client
	mq, err := imapmq.New(imapmq.Config{
		Login: "login",
		Passwd: "password",
		URL: "imap.gmail.com",
	})
	if err != nil {
		log.Panic(err)
	}
	defer mq.Close()

	// Create a queue based on INBOX
	q, err := mq.Queue("INBOX")
	if err != nil {
		log.Panic(err)
	}

	go func() {
		// Subscribe to messages with the "chat" subject
		c := q.Sub("chat")
		for msg := range c { // msg is a mail.Message instance.
			log.Printf("%s", msg.Header.Get("Subject"))
		}
	}()

	// We scan stdin for user input
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		// Publish a message with the "chat" subject in the INBOX queue
		q.Pub("chat", []byte(scanner.Text()))
	}
}

Documentation

https://godoc.org/github.com/mikaa123/imapmq

License

MIT © Michael Sokol

More Repositories

1

linear

Ruler app with web-development in mind
JavaScript
261
star
2

umlify

umlifies your projects.
Ruby
91
star
3

catnap

Simple Resource-oriented architecture for node
JavaScript
75
star
4

chimney

Chimney consumes logs to keep you warm.
JavaScript
38
star
5

rdci

Data Context Interaction module for Ruby
Ruby
10
star
6

lilp

lightweight literate programming
Ruby
10
star
7

Curby

Currying in Ruby
Ruby
5
star
8

express-remote_control

Minimalist hypermedia-inspired rest library to build apis with express.
JavaScript
4
star
9

allegory

Takes your js, turns it into an executable ascii image.
JavaScript
4
star
10

ShoesPARQL

Make SPARQL queries using Shoes ruby GUI!
Ruby
3
star
11

api-blueprint-visitors

Visitors for API-Blueprint's AST
JavaScript
3
star
12

hichievement

Your cloud-based activity log
Ruby
3
star
13

SparqlTransmission

Ruby class to wrap SPARQL request to a SPARQL end-point and handle the response in a nice, ruby fashion
Ruby
3
star
14

lilplateform

Literate programing plateformer
Ruby
2
star
15

linear-website

The web home of Linear
CSS
2
star
16

whats

A persistant hash to use as a memo in your terminal
Ruby
2
star
17

im

A tool to document what you're doing in a project.
Ruby
2
star
18

polaroidify

Create hipsterish polaroids from your jpegs. You know you want to!
Ruby
2
star
19

koa-router-controller

Controllers with a Rails-like RESTful interface for koa
JavaScript
2
star
20

EvilLeague

This is clearly the darkest timeline.
Ruby
2
star
21

SinatraSparql

Sinatra interface for SPARQL queries
Ruby
2
star
22

umlify2

umlify2
Ruby
1
star
23

cui

JavaScript
1
star
24

geoclustering_example

JavaScript
1
star