Commit from GitHub Actions (Generate Clients & Examples)

This commit is contained in:
asim
2021-11-02 16:44:07 +00:00
parent bc050eb7e1
commit c9791c4dc4
9 changed files with 112 additions and 27 deletions

View File

@@ -0,0 +1,6 @@
curl "https://api.m3o.com/v1/event/Consume" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $MICRO_API_TOKEN" \
-d '{
"topic": "user"
}'

View File

@@ -0,0 +1,17 @@
package example
import (
"fmt"
"os"
"github.com/micro/services/clients/go/event"
)
// Consume events from a given topic.
func ConsumeFromAtopic() {
eventService := event.NewEventService(os.Getenv("MICRO_API_TOKEN"))
rsp, err := eventService.Consume(&event.ConsumeRequest{
Topic: "user",
})
fmt.Println(rsp, err)
}

View File

@@ -0,0 +1,12 @@
const { EventService } = require("m3o/event");
// Consume events from a given topic.
async function consumeFromAtopic() {
let eventService = new EventService(process.env.MICRO_API_TOKEN);
let rsp = await eventService.consume({
topic: "user",
});
console.log(rsp);
}
consumeFromAtopic();

View File

@@ -0,0 +1,11 @@
curl "https://api.m3o.com/v1/event/Publish" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $MICRO_API_TOKEN" \
-d '{
"message": {
"id": "1",
"type": "signup",
"user": "john"
},
"topic": "user"
}'

View File

@@ -0,0 +1,22 @@
package example
import (
"fmt"
"os"
"github.com/micro/services/clients/go/event"
)
// Publish a event to the event stream.
func PublishAnEvent() {
eventService := event.NewEventService(os.Getenv("MICRO_API_TOKEN"))
rsp, err := eventService.Publish(&event.PublishRequest{
Message: map[string]interface{}{
"id": "1",
"type": "signup",
"user": "john",
},
Topic: "user",
})
fmt.Println(rsp, err)
}

View File

@@ -0,0 +1,17 @@
const { EventService } = require("m3o/event");
// Publish a event to the event stream.
async function publishAnEvent() {
let eventService = new EventService(process.env.MICRO_API_TOKEN);
let rsp = await eventService.publish({
message: {
id: "1",
type: "signup",
user: "john",
},
topic: "user",
});
console.log(rsp);
}
publishAnEvent();

View File

@@ -12,9 +12,9 @@ func PublishAmessage() {
mqService := mq.NewMqService(os.Getenv("MICRO_API_TOKEN"))
rsp, err := mqService.Publish(&mq.PublishRequest{
Message: map[string]interface{}{
"id": "1",
"type": "signup",
"user": "john",
"id": "1",
},
Topic: "events",
})