mirror of
https://github.com/kevin-DL/m3o-go.git
synced 2026-01-11 18:44:26 +00:00
31 lines
415 B
Go
Executable File
31 lines
415 B
Go
Executable File
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"go.m3o.com/mq"
|
|
)
|
|
|
|
// Subscribe to messages for a given topic.
|
|
func main() {
|
|
mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN"))
|
|
stream, err := mqService.Subscribe(&mq.SubscribeRequest{
|
|
Topic: "events",
|
|
})
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
|
|
for {
|
|
rsp, err := stream.Recv()
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
|
|
fmt.Println(rsp)
|
|
}
|
|
}
|