Skip to content

official-stallion/stallion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 Cannot retrieve latest commit at this time.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

logo

go version version
version version version

Fast message broker implemented with Golang programming language.
Using no external libraries, just internal Golang libraries.

How to use?

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.

Create server in Golang

package main

import "github.com/amirhnajafiz/stallion"

func main() {
	if err := stallion.NewServer(":9090"); err != nil {
		panic(err)
	}
}

Create a server with docker

Check the docker documentation for stallion server.

Creating Clients

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)
	}
}

Subscribe on a topic

client.Subscribe("topic", func(data []byte) {
    // any handler that you want
    fmt.Println(string(data))
})

Publish over a topic

client.Publish("topic", []byte("Hello"))

Unsubscribe from a topic

client.Unsubscribe("topic")