From 767935fafe37309975cfa1d305d2866597663091 Mon Sep 17 00:00:00 2001 From: amirhnajafiz Date: Sun, 19 Feb 2023 15:55:09 +0330 Subject: [PATCH] remove: all clients --- README.md | 72 ++-------------------- example/{server => }/auth-server/main.go | 0 example/{server => }/simple-server/main.go | 0 go.mod | 2 +- go.sum | 2 + 5 files changed, 9 insertions(+), 67 deletions(-) rename example/{server => }/auth-server/main.go (100%) rename example/{server => }/simple-server/main.go (100%) diff --git a/README.md b/README.md index e931013..431a965 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@

go version -version
+version
version version version @@ -17,15 +17,12 @@ Using no external libraries, just internal Golang libraries. - [Install Stallion](#how-to-use) - [Setup Stallion Server](#create-server-in-golang) - [Using Docker](#create-a-server-with-docker) -- [Stallion Go SDK](#creating-clients) - - [Subscribe](#subscribe-on-a-topic) - - [Publish](#publish-over-a-topic) - - [Unsubscribe](#unsubscribe-from-a-topic) - [Auth](#creating-a-server-with-auth) -- [Mock](#mock) ## How to use? + Get package: + ```shell go get github.com/official-stallion/stallion@latest ``` @@ -34,6 +31,7 @@ Now to set the client up you need to create a **stallion** server.
Stallion server is the message broker server. ### Create server in Golang + ```go package main @@ -47,47 +45,11 @@ func main() { ``` ### Create a server with docker -Check the docker [documentation](./docker/README.md) for stallion server. - -### Creating Clients -You can connect to stallion server like the example below: -```go -package main - -import ( - "fmt" - "time" - - "github.com/official-stallion/stallion" -) - -func main() { - client, err := stallion.NewClient("st://localhost:9090") - if err != nil { - panic(err) - } -} -``` - -### Subscribe on a topic -```go -client.Subscribe("topic", func(data []byte) { - // any handler that you want - fmt.Println(string(data)) -}) -``` - -### Publish over a topic -```go -client.Publish("topic", []byte("Hello")) -``` -### Unsubscribe from a topic -```go -client.Unsubscribe("topic") -``` +Check the docker [documentation](./docker/README.md) for stallion server. ## Creating a server with Auth + You can create a Stallion server with username and password for Auth. ```go package main @@ -100,25 +62,3 @@ func main() { } } ``` - -Now you can connect with username and password set in url. -```go -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: -```go -package main - -import "github.com/official-stallion/stallion" - -func main() { - client := stallion.NewMockClient() - - client.Publish("topic", []byte("message")) -} -``` diff --git a/example/server/auth-server/main.go b/example/auth-server/main.go similarity index 100% rename from example/server/auth-server/main.go rename to example/auth-server/main.go diff --git a/example/server/simple-server/main.go b/example/simple-server/main.go similarity index 100% rename from example/server/simple-server/main.go rename to example/simple-server/main.go diff --git a/go.mod b/go.mod index 078d266..c48d838 100644 --- a/go.mod +++ b/go.mod @@ -2,4 +2,4 @@ module github.com/official-stallion/stallion go 1.20 -require github.com/official-stallion/go-sdk v0.0.0-20230219120730-4b62373eac7b // indirect +require github.com/official-stallion/go-sdk v0.1.0 // indirect diff --git a/go.sum b/go.sum index 573a451..3564ed4 100644 --- a/go.sum +++ b/go.sum @@ -1,2 +1,4 @@ github.com/official-stallion/go-sdk v0.0.0-20230219120730-4b62373eac7b h1:RIgdFz75CPXOGWQYKunxkmUg5FXhtlU2P2QkY4TZ1Ss= github.com/official-stallion/go-sdk v0.0.0-20230219120730-4b62373eac7b/go.mod h1:m76X/qZ67EbfNJ1mWP7RSpPly3M5RxI3Jx2L3rKKToo= +github.com/official-stallion/go-sdk v0.1.0 h1:N5Yxgsh8t4VvhndigIv/SX6rennLtIyj4onNTgOOaK0= +github.com/official-stallion/go-sdk v0.1.0/go.mod h1:m76X/qZ67EbfNJ1mWP7RSpPly3M5RxI3Jx2L3rKKToo=