An MQTT broker library for Golang, using RabbitMQ as backend.
This project is under development and not production ready. Issues and contributions are wellcomed.
- support running standalone or being embed in your own application as golang library.
- based on RabbitMQ's stable, reliable and efficient message service.
- suport QoS 0 and 1.
- easy to scale up because of the share nothing implementation.
- extend topic schema to support RPC(non-mqtt-official).
- suport QoS 2.
- suport websocket proxy.
- suport TLS/SSL.
(package management depends on glide, install it first and run glide install
in the projectv folder)
the standalone borker is in ./standalone
, you can build and run it as you like.
-rabbit=xxx
: follw rabbitmq uri schema. example:-rabbit=amqp://user:pass@host:10000/vhost
package main
import (
"github.com/ruizeng/magina"
)
func authenticate(client *magina.Client, username string, password string) bool {
return true
}
func authorizePublish(client *magina.Client, topic string) bool {
return true
}
func authorizeSubscribe(client *magina.Client, topic string) bool {
return true
}
func main() {
server := &magina.Broker{
// server address to listen
Addr: ":1883",
// rabbit uri
RabbitURI: "amqp://guest:guest@localhost:5672/",
// callbacks
Authenticate: authenticate,
AuthorizePublish: authorizePublish,
AuthorizeSubscribe: authorizeSubscribe,
}
server.ListenAndServe()
return
}