Fast message broker implemented with Golang programming language.
Using no external libraries, just internal Golang libraries.
Get package:
go get github.com/amirhnajafiz/stallion@latest
Now to set the client up you need to create a stallion server.
Stallion server is the message broker server.
package main
import "github.com/amirhnajafiz/stallion"
func main() {
if err := stallion.NewServer(":9090"); err != nil {
panic(err)
}
}
Check the docker documentation for stallion server.
You can connect to stallion server like the example below:
package main
import (
"fmt"
"time"
"github.com/amirhnajafiz/stallion"
)
func main() {
client, err := stallion.NewClient("localhost:9090")
if err != nil {
panic(err)
}
}
client.Subscribe("topic", func(data []byte) {
// any handler that you want
fmt.Println(string(data))
})
client.Publish("topic", []byte("Hello"))
client.Unsubscribe("topic")