Commit from GitHub Actions (Generate Clients & Examples)

This commit is contained in:
asim
2021-11-02 13:52:03 +00:00
parent c1c6c1e08c
commit 6f69ef3fb3
13 changed files with 148 additions and 4 deletions

View File

@@ -12,10 +12,10 @@ func CreateArecord() {
dbService := db.NewDbService(os.Getenv("MICRO_API_TOKEN"))
rsp, err := dbService.Create(&db.CreateRequest{
Record: map[string]interface{}{
"age": 42,
"isActive": true,
"id": "1",
"name": "Jane",
"age": 42,
"isActive": true,
},
Table: "users",
})

View File

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

View File

@@ -0,0 +1,22 @@
package example
import (
"fmt"
"os"
"github.com/micro/services/clients/go/mq"
)
// Publish a message to the mq. Specify a topic to group messages for a specific topic.
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",
},
Topic: "events",
})
fmt.Println(rsp, err)
}

View File

@@ -0,0 +1,17 @@
const { MqService } = require("m3o/mq");
// Publish a message to the mq. Specify a topic to group messages for a specific topic.
async function publishAmessage() {
let mqService = new MqService(process.env.MICRO_API_TOKEN);
let rsp = await mqService.publish({
message: {
id: "1",
type: "signup",
user: "john",
},
topic: "events",
});
console.log(rsp);
}
publishAmessage();

View File

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

View File

@@ -0,0 +1,17 @@
package example
import (
"fmt"
"os"
"github.com/micro/services/clients/go/mq"
)
// Subscribe to messages for a given topic.
func SubscribeToAtopic() {
mqService := mq.NewMqService(os.Getenv("MICRO_API_TOKEN"))
rsp, err := mqService.Subscribe(&mq.SubscribeRequest{
Topic: "events",
})
fmt.Println(rsp, err)
}

View File

@@ -0,0 +1,12 @@
const { MqService } = require("m3o/mq");
// Subscribe to messages for a given topic.
async function subscribeToAtopic() {
let mqService = new MqService(process.env.MICRO_API_TOKEN);
let rsp = await mqService.subscribe({
topic: "events",
});
console.log(rsp);
}
subscribeToAtopic();

View File

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