Skip to content

Latest commit

 

History

20 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stallion Golang SDK


Golang client SDK for Stallion message broker.

How to use?

Get package:

go get github.com/official-stallion/go-sdk@latest

Creating Clients

You can connect to stallion server like the example below:

package main

import (
	"fmt"
	"time"

	sdk "github.com/official-stallion/go-sdk"
)

func main() {
	client, err := sdk.NewClient("st://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")

Connect with Auth

Connect with username and password set in url:

client, err := stallion.NewClient("st://root:Pa$$word@localhost:9090")
if err != nil {
    panic(err)
}

Mock

You can create a mock client to create a stallion client sample:

package main

import sdk "github.com/official-stallion/go-sdk"

func main() {
	client := sdk.NewMockClient()
	
	client.Publish("topic", []byte("message"))
}

About

Golang client SDK for Stallion message broker.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages