From 9b392559a66d5fc70f018d9fa7b8e010b117c396 Mon Sep 17 00:00:00 2001 From: amirhnajafiz Date: Wed, 10 Aug 2022 16:55:19 +0430 Subject: [PATCH] update: readme --- README.md | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f0adebf..8576bd8 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,51 @@ -# Stallion +

+Stallion +

Message broker with Golang. + +## How to use? +Get package: +```shell +go get github.com/amirhnajafiz/stallion +``` + +### Client +```go +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) { + fmt.Println(string(data)) + }) + + client.Publish("topic", []byte("Hello")) + + time.Sleep(3 * time.Second) +} +``` + +### Server +```go +package main + +import "github.com/amirhnajafiz/stallion" + +func main() { + if err := stallion.NewServer(":9090"); err != nil { + panic(err) + } +} +```