msgo

module
v0.0.0-...-60b9055 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2019 License: MIT

README

msgo

Build Status Coverage Status Go Report Card Docker Repository on Quay

A high performance message middleware, based on pub/sub model.

Install

git get -u github.com/buptmiao/msgo

Features

  • Msgo uses gogoprotobuf as binary interface, gogoprotobuf is an optimized version of goprotobuf with high performance on marshaling and unmarshaling msgs and lower memory cost. For more information about gogoprotobuf, see this benchmark

  • Support batch messages pub/sub, producer can publish multiple messages at a time. The broker can compose messages from different producer into a batch package, and deliver them to a subscriber at a time.

  • Support REST API, which is used to deliver messages and monitor the runtime statistics of msgo. Msgo exports the metrics as prometheus expected, that means we can collect the metrics into prometheus, and monitor the state of msgo.

  • Msgo supports two kind of message type: persist and non-persist, with non-persist type, messages are stored in memory, and with persist type, messages are stored into disk. Msgo supports two kinds of persistence strategy, Boltdb and customized AOF storage which is inspired by redis aof.

How to use

subscribe a topic with a filter
consumer := client.NewConsumer(addr)  //addr is the address of broker, eg: localhost:13001
consumer.Subscribe("msgo", "filter", func(m ...*msg.Message) error {
    for _, v := range m {
        fmt.Println(string(v.GetBody()))
    }
    return nil
})
publish a message
producer := client.NewProducer(addr)
_ = producer.PublishFanout("msgo", "filter", []byte("hello world"))

then the subscriber will received a message "hello world".

Please see the demo for details.

Docker

docker pull buptmiao/msgo
docker run --name broker -p 13000:13000 -p 13001:13001 buptmiao/msgo

More updates

Directories

Path Synopsis
examples
Package msg is a generated protocol buffer package.
Package msg is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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