Skip to content

Commit

Permalink
remove: all clients
Browse files Browse the repository at this point in the history
  • Loading branch information
amirhnajafiz committed Feb 19, 2023
1 parent a138e4c commit 767935f
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 67 deletions.
72 changes: 6 additions & 66 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<p align="center">
<img src="https://img.shields.io/badge/Golang-1.19-66ADD8?style=for-the-badge&logo=go" alt="go version" />
<img src="https://img.shields.io/badge/Version-1.2.2-red?style=for-the-badge&logo=github" alt="version" /><br />
<img src="https://img.shields.io/badge/Version-1.3.0-red?style=for-the-badge&logo=github" alt="version" /><br />
<img src="https://img.shields.io/badge/MacOS-black?style=for-the-badge&logo=apple" alt="version" />
<img src="https://img.shields.io/badge/Linux-white?style=for-the-badge&logo=linux" alt="version" />
<img src="https://img.shields.io/badge/Windows-blue?style=for-the-badge&logo=windows" alt="version" />
Expand All @@ -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
```
Expand All @@ -34,6 +31,7 @@ Now to set the client up you need to create a **stallion** server.<br />
Stallion server is the message broker server.

### Create server in Golang

```go
package main

Expand All @@ -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
Expand All @@ -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"))
}
```
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=

0 comments on commit 767935f

Please sign in to comment.