mirror of
https://github.com/kevin-DL/m3o-go.git
synced 2026-01-23 23:21:27 +00:00
Merge branch 'master' of ssh://github.com/m3o/m3o-go
This commit is contained in:
33
README.md
33
README.md
@@ -1,6 +1,8 @@
|
|||||||
# M3O Go Client
|
# M3O Go Client
|
||||||
|
|
||||||
By default the client connects to api.m3o.com/client
|
This is the Go client to access APIs on the M3O Platform
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package main
|
package main
|
||||||
@@ -33,28 +35,18 @@ func main() {
|
|||||||
req := &Request{
|
req := &Request{
|
||||||
Name: "John",
|
Name: "John",
|
||||||
}
|
}
|
||||||
|
|
||||||
var rsp Response
|
var rsp Response
|
||||||
|
|
||||||
if err := c.Call("greeter", "Say.Hello", req, &rsp); err != nil {
|
if err := c.Call("helloworld", "call", req, &rsp); err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println(rsp)
|
fmt.Println(rsp)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
If you want to access your local micro:
|
|
||||||
|
|
||||||
```go
|
|
||||||
c := client.NewClient(client.Options{Local: true})
|
|
||||||
```
|
|
||||||
|
|
||||||
You can also set the api address explicitly:
|
|
||||||
|
|
||||||
```go
|
|
||||||
c := client.NewClient(client.Options{Address: "https://api.yourdomain.com/client"})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Streaming
|
## Streaming
|
||||||
|
|
||||||
The client supports streaming
|
The client supports streaming
|
||||||
@@ -76,10 +68,17 @@ type Response struct {
|
|||||||
Count string `json:"count"`
|
Count string `json:"count"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
var (
|
||||||
c := client.NewClient(&client.Options{Local: true})
|
token, _ = os.Getenv("TOKEN")
|
||||||
|
)
|
||||||
|
|
||||||
stream, err := c.Stream("example", "Streamer.ServerStream", Request{Count: "10"})
|
func main() {
|
||||||
|
c := client.NewClient(nil)
|
||||||
|
|
||||||
|
// set your api token
|
||||||
|
c.SetToken(token)
|
||||||
|
|
||||||
|
stream, err := c.Stream("streams", "subscribe", Request{Count: "10"})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user