mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-15 04:24:44 +00:00
Commit from GitHub Actions (Generate Clients & Examples)
This commit is contained in:
@@ -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",
|
||||
})
|
||||
|
||||
11
examples/event/publish/curl/publishAMessage.sh
Executable file
11
examples/event/publish/curl/publishAMessage.sh
Executable 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"
|
||||
}'
|
||||
22
examples/event/publish/go/publishAMessage.go
Executable file
22
examples/event/publish/go/publishAMessage.go
Executable 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)
|
||||
}
|
||||
17
examples/event/publish/node/publishAMessage.js
Executable file
17
examples/event/publish/node/publishAMessage.js
Executable 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();
|
||||
6
examples/event/subscribe/curl/subscribeToATopic.sh
Executable file
6
examples/event/subscribe/curl/subscribeToATopic.sh
Executable 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"
|
||||
}'
|
||||
17
examples/event/subscribe/go/subscribeToATopic.go
Executable file
17
examples/event/subscribe/go/subscribeToATopic.go
Executable 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)
|
||||
}
|
||||
12
examples/event/subscribe/node/subscribeToATopic.js
Executable file
12
examples/event/subscribe/node/subscribeToATopic.js
Executable 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();
|
||||
@@ -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(¬es.EventsRequest{
|
||||
|
||||
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user