mirror of
https://github.com/kevin-DL/m3o-go.git
synced 2026-01-18 13:15:08 +00:00
Commit from m3o/m3o action
This commit is contained in:
@@ -6,7 +6,7 @@ Endpoints:
|
||||
|
||||
## Publish
|
||||
|
||||
Publish a message to the event stream.
|
||||
Publish a event to the event stream.
|
||||
|
||||
|
||||
[https://m3o.com/event/api#Publish](https://m3o.com/event/api#Publish)
|
||||
@@ -21,8 +21,8 @@ import(
|
||||
"go.m3o.com/event"
|
||||
)
|
||||
|
||||
// Publish a message to the event stream.
|
||||
func PublishAmessage() {
|
||||
// Publish a event to the event stream.
|
||||
func PublishAnEvent() {
|
||||
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := eventService.Publish(&event.PublishRequest{
|
||||
Message: map[string]interface{}{
|
||||
@@ -36,12 +36,12 @@ Topic: "user",
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
||||
## Subscribe
|
||||
## Consume
|
||||
|
||||
Subscribe to messages for a given topic.
|
||||
Consume events from a given topic.
|
||||
|
||||
|
||||
[https://m3o.com/event/api#Subscribe](https://m3o.com/event/api#Subscribe)
|
||||
[https://m3o.com/event/api#Consume](https://m3o.com/event/api#Consume)
|
||||
|
||||
```go
|
||||
package example
|
||||
@@ -53,10 +53,10 @@ import(
|
||||
"go.m3o.com/event"
|
||||
)
|
||||
|
||||
// Subscribe to messages for a given topic.
|
||||
func SubscribeToAtopic() {
|
||||
// Consume events from a given topic.
|
||||
func ConsumeFromAtopic() {
|
||||
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := eventService.Subscribe(&event.SubscribeRequest{
|
||||
rsp, err := eventService.Consume(&event.ConsumeRequest{
|
||||
Topic: "user",
|
||||
|
||||
})
|
||||
|
||||
17
examples/event/consume/consumeFromATopic.go
Executable file
17
examples/event/consume/consumeFromATopic.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/event"
|
||||
)
|
||||
|
||||
// Consume events from a given topic.
|
||||
func ConsumeFromAtopic() {
|
||||
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := eventService.Consume(&event.ConsumeRequest{
|
||||
Topic: "user",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
22
examples/event/publish/publishAnEvent.go
Executable file
22
examples/event/publish/publishAnEvent.go
Executable file
@@ -0,0 +1,22 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.m3o.com/event"
|
||||
)
|
||||
|
||||
// Publish a event to the event stream.
|
||||
func PublishAnEvent() {
|
||||
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
|
||||
rsp, err := eventService.Publish(&event.PublishRequest{
|
||||
Message: map[string]interface{}{
|
||||
"id": "1",
|
||||
"type": "signup",
|
||||
"user": "john",
|
||||
},
|
||||
Topic: "user",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
Reference in New Issue
Block a user