Files
m3o-go/examples/mq
2021-11-02 14:06:57 +00:00
..
2021-11-02 14:03:39 +00:00
2021-11-02 13:52:46 +00:00
2021-11-02 14:06:57 +00:00

Mq

An m3o.com API. For example usage see m3o.com/Mq/api.

Endpoints:

Publish

Publish a message to the mq. Specify a topic to group messages for a specific topic.

https://m3o.com/mq/api#Publish

package example

import(
	"fmt"
	"os"

	"go.m3o.com/mq"
)

// Publish a message to the mq. Specify a topic to group messages for a specific topic.
func PublishAmessage() {
	mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN"))
	rsp, err := mqService.Publish(&mq.PublishRequest{
		Message: map[string]interface{}{
	"type": "signup",
	"user": "john",
	"id": "1",
},
Topic: "events",

	})
	fmt.Println(rsp, err)
}

Subscribe

Subscribe to messages for a given topic.

https://m3o.com/mq/api#Subscribe

package example

import(
	"fmt"
	"os"

	"go.m3o.com/mq"
)

// Subscribe to messages for a given topic.
func SubscribeToAtopic() {
	mqService := mq.NewMqService(os.Getenv("M3O_API_TOKEN"))
	rsp, err := mqService.Subscribe(&mq.SubscribeRequest{
		Topic: "events",

	})
	fmt.Println(rsp, err)
}