Commit from GitHub Actions (Generate Clients & Examples)

This commit is contained in:
asim
2021-11-02 13:30:51 +00:00
parent 2dbc66ebd7
commit 93b1c73b18
15 changed files with 151 additions and 5 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{}{
"id": "1",
"name": "Jane",
"age": 42,
"isActive": true,
"id": "1",
},
Table: "users",
})

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 message to the event. Specify a topic to group messages for a specific topic.
func PublishAmessage() {
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 message to the event. Specify a topic to group messages for a specific topic.
async function publishAmessage() {
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);
}
publishAmessage();

View File

@@ -0,0 +1,6 @@
curl "https://api.m3o.com/v1/event/Subscribe" \
-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"
)
// Subscribe to messages for a given topic.
func SubscribeToAtopic() {
eventService := event.NewEventService(os.Getenv("MICRO_API_TOKEN"))
rsp, err := eventService.Subscribe(&event.SubscribeRequest{
Topic: "user",
})
fmt.Println(rsp, err)
}

View File

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

View File

@@ -7,7 +7,7 @@ import (
"github.com/micro/services/clients/go/notes"
)
// Specify the note to events
// Subscribe to notes events
func SubscribeToEvents() {
notesService := notes.NewNotesService(os.Getenv("MICRO_API_TOKEN"))
rsp, err := notesService.Events(&notes.EventsRequest{

View File

@@ -1,6 +1,6 @@
const { NotesService } = require("m3o/notes");
// Specify the note to events
// Subscribe to notes events
async function subscribeToEvents() {
let notesService = new NotesService(process.env.MICRO_API_TOKEN);
let rsp = await notesService.events({