Skip to content

mongomq is a pub/sub implementation for golang and MongoDB.

Notifications You must be signed in to change notification settings

gnasnik/mongomq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mongomq

mongomq is a pub/sub implementation for golang and MongoDB.

Install

go get -v github.com/frankffenn/mongomq

Example

package main

import (
	"context"
	"log"

	mq "github.com/frankffenn/mongomq"
)

func main() {
	ctx := context.Background()
	c, err := mq.NewChannel(ctx,
		mq.Database("testdb"),
		mq.Topic("testtopic"),
	)

	if err != nil {
		log.Fatal(err)
	}

	go func() {
		for i := 0; i < 10; i++ {
			c.Publish("testtopic", "hi")
		}
	}()

	data, err := c.Subscribe("testtopic")
	if err != nil {
		log.Fatal(err)
	}

	for {
		select {
		case msg := <-data:
			println(msg)
		}
	}

}

run example

    cd example/
    MONGO_URI="mongodb://admin:example@127.0.0.1:27017/lotus?authsource=admin" go run  *.go

View the MongoMQ Example

Status

Just for testing. This isn't used in production yet.

About

mongomq is a pub/sub implementation for golang and MongoDB.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages