From 072104d1969908f060dc791faad3726f031ae714 Mon Sep 17 00:00:00 2001 From: asim Date: Wed, 3 Nov 2021 16:07:49 +0000 Subject: [PATCH] Commit from GitHub Actions (Generate Clients & Examples) --- clients/go/stream/stream.go | 19 +++++++++++++++++++ clients/ts/package.json | 2 +- examples/db/create/go/createARecord.go | 4 ++-- examples/event/publish/go/publishAnEvent.go | 2 +- .../createChannel/curl/createChannel.sh | 7 +++++++ .../stream/createChannel/go/createChannel.go | 19 +++++++++++++++++++ .../createChannel/node/createChannel.js | 14 ++++++++++++++ 7 files changed, 63 insertions(+), 4 deletions(-) create mode 100755 examples/stream/createChannel/curl/createChannel.sh create mode 100755 examples/stream/createChannel/go/createChannel.go create mode 100755 examples/stream/createChannel/node/createChannel.js diff --git a/clients/go/stream/stream.go b/clients/go/stream/stream.go index 3fc1253..fec66b9 100755 --- a/clients/go/stream/stream.go +++ b/clients/go/stream/stream.go @@ -16,6 +16,13 @@ type StreamService struct { client *client.Client } +// Create a channel with a given name and description. Channels are created automatically but +// this allows you to specify a description that's persisted for the lifetime of the channel. +func (t *StreamService) CreateChannel(request *CreateChannelRequest) (*CreateChannelResponse, error) { + rsp := &CreateChannelResponse{} + return rsp, t.client.Call("stream", "CreateChannel", request, rsp) +} + // List all the active channels func (t *StreamService) ListChannels(request *ListChannelsRequest) (*ListChannelsResponse, error) { rsp := &ListChannelsResponse{} @@ -35,12 +42,24 @@ func (t *StreamService) SendMessage(request *SendMessageRequest) (*SendMessageRe } type Channel struct { + // description for the channel + Description string `json:"description"` // last activity time LastActive string `json:"lastActive"` // name of the channel Name string `json:"name"` } +type CreateChannelRequest struct { + // description for the channel + Description string `json:"description"` + // name of the channel + Name string `json:"name"` +} + +type CreateChannelResponse struct { +} + type ListChannelsRequest struct { } diff --git a/clients/ts/package.json b/clients/ts/package.json index 566ac13..400e525 100644 --- a/clients/ts/package.json +++ b/clients/ts/package.json @@ -78,5 +78,5 @@ "prepare": "npm run build" }, "types": "index.d.ts", - "version": "1.0.620" + "version": "1.0.621" } \ No newline at end of file diff --git a/examples/db/create/go/createARecord.go b/examples/db/create/go/createARecord.go index 283dd5d..08be46f 100755 --- a/examples/db/create/go/createARecord.go +++ b/examples/db/create/go/createARecord.go @@ -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", + "name": "Jane", }, Table: "users", }) diff --git a/examples/event/publish/go/publishAnEvent.go b/examples/event/publish/go/publishAnEvent.go index a6a3b0e..cd945dc 100755 --- a/examples/event/publish/go/publishAnEvent.go +++ b/examples/event/publish/go/publishAnEvent.go @@ -12,9 +12,9 @@ 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", - "id": "1", }, Topic: "user", }) diff --git a/examples/stream/createChannel/curl/createChannel.sh b/examples/stream/createChannel/curl/createChannel.sh new file mode 100755 index 0000000..bb90bb6 --- /dev/null +++ b/examples/stream/createChannel/curl/createChannel.sh @@ -0,0 +1,7 @@ +curl "https://api.m3o.com/v1/stream/CreateChannel" \ +-H "Content-Type: application/json" \ +-H "Authorization: Bearer $MICRO_API_TOKEN" \ +-d '{ + "description": "The channel for all things", + "name": "general" +}' \ No newline at end of file diff --git a/examples/stream/createChannel/go/createChannel.go b/examples/stream/createChannel/go/createChannel.go new file mode 100755 index 0000000..9b3a6f6 --- /dev/null +++ b/examples/stream/createChannel/go/createChannel.go @@ -0,0 +1,19 @@ +package example + +import ( + "fmt" + "os" + + "github.com/micro/services/clients/go/stream" +) + +// Create a channel with a given name and description. Channels are created automatically but +// this allows you to specify a description that's persisted for the lifetime of the channel. +func CreateChannel() { + streamService := stream.NewStreamService(os.Getenv("MICRO_API_TOKEN")) + rsp, err := streamService.CreateChannel(&stream.CreateChannelRequest{ + Description: "The channel for all things", + Name: "general", + }) + fmt.Println(rsp, err) +} diff --git a/examples/stream/createChannel/node/createChannel.js b/examples/stream/createChannel/node/createChannel.js new file mode 100755 index 0000000..d878b13 --- /dev/null +++ b/examples/stream/createChannel/node/createChannel.js @@ -0,0 +1,14 @@ +const { StreamService } = require("m3o/stream"); + +// Create a channel with a given name and description. Channels are created automatically but +// this allows you to specify a description that's persisted for the lifetime of the channel. +async function createChannel() { + let streamService = new StreamService(process.env.MICRO_API_TOKEN); + let rsp = await streamService.createChannel({ + description: "The channel for all things", + name: "general", + }); + console.log(rsp); +} + +createChannel();