A high performance message middleware, based on pub/sub model.
git get -u github.com/buptmiao/msgo
-
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.
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
})
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 pull buptmiao/msgo
docker run --name broker -p 13000:13000 -p 13001:13001 buptmiao/msgo