Files
2021-11-02 16:01:40 +00:00
..
2021-11-02 16:01:40 +00:00
2021-11-02 13:31:19 +00:00
2021-11-02 16:01:40 +00:00

Event

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

Endpoints:

Publish

Publish a message to the event stream.

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

package example

import(
	"fmt"
	"os"

	"go.m3o.com/event"
)

// Publish a message to the event stream.
func PublishAmessage() {
	eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
	rsp, err := eventService.Publish(&event.PublishRequest{
		Message: map[string]interface{}{
	"user": "john",
	"id": "1",
	"type": "signup",
},
Topic: "user",

	})
	fmt.Println(rsp, err)
}

Subscribe

Subscribe to messages for a given topic.

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

package example

import(
	"fmt"
	"os"

	"go.m3o.com/event"
)

// Subscribe to messages for a given topic.
func SubscribeToAtopic() {
	eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
	rsp, err := eventService.Subscribe(&event.SubscribeRequest{
		Topic: "user",

	})
	fmt.Println(rsp, err)
}