mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-21 23:15:06 +00:00
Commit from GitHub Actions (Generate Clients & Examples)
This commit is contained in:
@@ -23,6 +23,7 @@ import (
|
||||
"github.com/micro/services/clients/go/image"
|
||||
"github.com/micro/services/clients/go/ip"
|
||||
"github.com/micro/services/clients/go/location"
|
||||
"github.com/micro/services/clients/go/mq"
|
||||
"github.com/micro/services/clients/go/notes"
|
||||
"github.com/micro/services/clients/go/otp"
|
||||
"github.com/micro/services/clients/go/postcode"
|
||||
@@ -72,6 +73,7 @@ func NewClient(token string) *Client {
|
||||
ImageService: image.NewImageService(token),
|
||||
IpService: ip.NewIpService(token),
|
||||
LocationService: location.NewLocationService(token),
|
||||
MqService: mq.NewMqService(token),
|
||||
NotesService: notes.NewNotesService(token),
|
||||
OtpService: otp.NewOtpService(token),
|
||||
PostcodeService: postcode.NewPostcodeService(token),
|
||||
@@ -121,6 +123,7 @@ type Client struct {
|
||||
ImageService *image.ImageService
|
||||
IpService *ip.IpService
|
||||
LocationService *location.LocationService
|
||||
MqService *mq.MqService
|
||||
NotesService *notes.NotesService
|
||||
OtpService *otp.OtpService
|
||||
PostcodeService *postcode.PostcodeService
|
||||
|
||||
51
clients/go/mq/mq.go
Executable file
51
clients/go/mq/mq.go
Executable file
@@ -0,0 +1,51 @@
|
||||
package mq
|
||||
|
||||
import (
|
||||
"github.com/m3o/m3o-go/client"
|
||||
)
|
||||
|
||||
func NewMqService(token string) *MqService {
|
||||
return &MqService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type MqService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Publish a message to the mq. Specify a topic to group messages for a specific topic.
|
||||
func (t *MqService) Publish(request *PublishRequest) (*PublishResponse, error) {
|
||||
rsp := &PublishResponse{}
|
||||
return rsp, t.client.Call("mq", "Publish", request, rsp)
|
||||
}
|
||||
|
||||
// Subscribe to messages for a given topic.
|
||||
func (t *MqService) Subscribe(request *SubscribeRequest) (*SubscribeResponse, error) {
|
||||
rsp := &SubscribeResponse{}
|
||||
return rsp, t.client.Call("mq", "Subscribe", request, rsp)
|
||||
}
|
||||
|
||||
type PublishRequest struct {
|
||||
// The json message to publish
|
||||
Message map[string]interface{} `json:"message"`
|
||||
// The topic to publish to
|
||||
Topic string `json:"topic"`
|
||||
}
|
||||
|
||||
type PublishResponse struct {
|
||||
}
|
||||
|
||||
type SubscribeRequest struct {
|
||||
// The topic to subscribe to
|
||||
Topic string `json:"topic"`
|
||||
}
|
||||
|
||||
type SubscribeResponse struct {
|
||||
// The next json message on the topic
|
||||
Message map[string]interface{} `json:"message"`
|
||||
// The topic subscribed to
|
||||
Topic string `json:"topic"`
|
||||
}
|
||||
Reference in New Issue
Block a user