srvpubsub

package
v0.6.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

README

Pub/Sub

Channel API

interface
GetChannels(ctx, cios.ApiGetChannelsRequest) (cios.MultipleChannel, *_nethttp.Response, error)
GetChannelsAll(ctx, cios.ApiGetChannelsRequest) ([]cios.Channel, *_nethttp.Response, error)
GetChannelsUnlimited(ctx, cios.ApiGetChannelsRequest) ([]cios.Channel, *_nethttp.Response, error)
GetChannel(ctx, string, *bool, *string) (cios.Channel, *_nethttp.Response, error)
GetChannelFirst(ctx, cios.ApiGetChannelsRequest) (cios.Channel, *_nethttp.Response, error)
GetChannelsMapByID(ctx, cios.ApiGetChannelsRequest) (map[string]cios.Channel, *_nethttp.Response, error)
GetChannelsMapByResourceOwnerID(ctx, cios.ApiGetChannelsRequest) (map[string][]cios.Channel, *_nethttp.Response, error)
DeleteChannel(ctx, string) (*_nethttp.Response, error)
GetOrCreateChannel(ctx, cios.ApiGetChannelsRequest, cios.ChannelProposal) (cios.Channel, *_nethttp.Response, error)
CreateChannel(ctx, cios.ChannelProposal) (cios.Channel, *_nethttp.Response, error)
UpdateChannel(ctx, string, cios.ChannelUpdateProposal) (cios.MultipleChannel, *_nethttp.Response, error)
Usage
Get a Channel
options := srvpubsub.MakeGetChannelsOpts
channel, httpResponse, err := client.PubSub().GetChannel(ctx, "channel_id", nil, nil)
Get Channels max limit 1000
options := srvpubsub.MakeGetChannelsOpts
channels, httpResponse, err := client.PubSub().GetChannels(ctx, options().Limit(500))
Get Channels no limit
options := srvpubsub.MakeGetChannelsOpts
channels, httpResponse, err := client.PubSub().GetChannelsAll(ctx, options().Limit(500))
Get Channels unlimited
options := srvpubsub.MakeGetChannelsOpts
channels, httpResponse, err := client.PubSub().GetChannelsUnlimited(ctx, options().Limit(500))
Get a Channel that is first Channels API
options := srvpubsub.MakeGetChannelsOpts
channel, httpResponse, err := client.PubSub().GetChannelFirst(ctx, options().Label("sample=test"))
Get Channel Map by Channel ID
options := srvpubsub.MakeGetChannelsOpts
channelMap, httpResponse, err := client.PubSub().GetChannelsMapByID(ctx, options().Label("sample=test"))
Get Channel Map by ResourceOwner ID
options := srvpubsub.MakeGetChannelsOpts
channelMap, httpResponse, err := client.PubSub().GetChannelsMapByResourceOwnerID(ctx, options().Label("sample=test"))
Get or Create a Channel
options := srvpubsub.MakeGetChannelsOpts
channel, httpResponse, err := client.PubSub().GetOrCreateChannel(ctx, options().Limit(500), cios.ChannelProposal{})
Create a Channel
channel, httpResponse, err := client.PubSub().CreateChannel(ctx,  cios.ChannelProposal{})
Update a Channel
_, httpResponse, err := client.PubSub().UpdateChannel(ctx,  cios.ChannelUpdateProposal{})
Delete a Channel
_, httpResponse, err := client.PubSub().UpdateChannel(ctx,  cios.ChannelUpdateProposal{})

Data Store API

interface
GetDataStoreChannels(ctx, cios.ApiGetDataStoreChannelsRequest) (cios.MultipleDataStoreChannel, *_nethttp.Response, error)
GetDataStoreChannel(ctx, string) (cios.DataStoreChannel, *_nethttp.Response, error)
GetObjects(ctx, string, cios.ApiGetDataStoreObjectsRequest) (cios.MultipleDataStoreObject, *_nethttp.Response, error)
GetObjectsAll(ctx, string, cios.ApiGetDataStoreObjectsRequest) ([]cios.DataStoreObject, *_nethttp.Response, error)
GetObjectsUnlimited(ctx, string, cios.ApiGetDataStoreObjectsRequest) ([]cios.DataStoreObject, *_nethttp.Response, error)
GetObject(ctx, string, string, *string) (interface{}, *_nethttp.Response, error)
GetObjectLatest(ctx, string, *string) (interface{}, *_nethttp.Response, error)
MapObjectLatest(ctx, string, *string, interface{}) (*_nethttp.Response, error)
GetMultiObjectLatest(ctx, []string) (cios.MultipleDataStoreDataLatest, *_nethttp.Response, error)
GetMultiObjectLatestByChannels(ctx, []cios.Channel) (cios.MultipleDataStoreDataLatest, *_nethttp.Response, error)
MapMultiObjectLatestPayload(ctx, []string, interface{}) ([]cios.PackerFormatJsonHeader, *_nethttp.Response, error)
MapMultiObjectLatestPayloadByChannels(ctx, []cios.Channel, interface{}) ([]cios.PackerFormatJsonHeader, *_nethttp.Response, error)
GetStream(ctx, string, sdkmodel.ApiGetStreamRequest) ([]string, error)
GetStreamAll(ctx, string, sdkmodel.ApiGetStreamRequest) ([]string, error)
GetStreamUnlimited(ctx, string, sdkmodel.ApiGetStreamRequest) ([]string, error)
MapStreamAll(ctx, string, sdkmodel.ApiGetStreamRequest, interface{}) error
MapStreamUnlimited(ctx, string, sdkmodel.ApiGetStreamRequest, interface{}) error
GetJsonStreamUnlimited(ctx, string, sdkmodel.ApiGetStreamRequest) ([]cios.PackerFormatJson, error)
GetStreamFirst(ctx, string, sdkmodel.ApiGetStreamRequest) (string, error)
MapStreamFirst(ctx, string, sdkmodel.ApiGetStreamRequest, interface{}) error
DeleteDataByChannel(ctx, string) (*_nethttp.Response, error)
DeleteObject(ctx, string, string) (*_nethttp.Response, error)
Usage
Get Channels on Data Store max limit 1000
options := srvpubsub.MakeGetDataStoreChannelsOpts()
channels, httpResponse, err := client.PubSub().GetDataStoreChannels(ctx, options().Limit(1000))
Get a Channel on Data Store
channel, httpResponse, err := client.PubSub().GetDataStoreChannel(ctx, "channel_id")
Get a DataStore Object

※ Fix in the future

packer_format := "payload_only"
object, httpResponse, err := client.PubSub().GetObject(ctx, "channel_id", "object_id", &packer_format)
Get latest DataStore Object

※ Fix in the future

packer_format := "payload_only"
object, httpResponse, err := client.PubSub().GetObjectLatest(ctx, "channel_id",  &packer_format)
Get latest DataStore Object on Channels
objects, httpResponse, err := client.PubSub().GetMultiObjectLatest(ctx, []string{"channel_id1", "channel_id2", "channel_id3"})
Get latest DataStore Object by Channels
objects, httpResponse, err := client.PubSub().GetMultiObjectLatest(ctx, []cios.Channel{channel1, channel2, channel3})
Get DataStore Objects max limit 1000
options := srvpubsub.MakeGetObjectsOpts
objects, httpResponse, err := client.PubSub().GetObjects(ctx, "channel_id", options())
Get DataStore Objects no limit
options := srvpubsub.MakeGetObjectsOpts
objects, httpResponse, err := client.PubSub().GetObjectsAll(ctx, "channel_id", options())
Get DataStore Objects unlimited
options := srvpubsub.MakeGetObjectsOpts
objects, httpResponse, err := client.PubSub().GetObjectsUnlimited(ctx, "channel_id", options())
Parse latest for Object
packerFormat := "payload_only"
sample := struct{....}{}
httpResponse, err := client.PubSub().MapObjectLatest(ctx, "channel_id", &packerFormat, &sample)
Parse latest for Object on channels

※ Fix in the future

packerFormat := "payload_only"
sample := struct{....}{}
httpResponse, err := client.PubSub().MapMultiObjectLatestPayload(ctx, []string{"channel_id", "channel_id"}, &sample)
Get DataStore Stream max limit 1000
options := srvpubsub.MakeGetStreamOpts
stream, err := client.PubSub().GetStream(ctx, "channel_id", options())
Get DataStore Stream no limit
options := srvpubsub.MakeGetStreamOpts
stream, err := client.PubSub().GetStreamAll(ctx, "channel_id", options())
Get DataStore Stream unlimited
options := srvpubsub.MakeGetStreamOpts
stream, err := client.PubSub().GetStreamUnimited(ctx, "channel_id", options())
Get a DataStore Stream first
options := srvpubsub.MakeGetStreamOpts
data, err := client.PubSub().GetStreamFirst(ctx, "channel_id", options())
Parse DataStore Stream no limit
data := []struct{...}{}
options := srvpubsub.MakeGetStreamOpts
err := client.PubSub().MapStreamAll(ctx, "channel_id", options(), &data)
Parse DataStore Stream unlimited
data := []struct{...}{}
options := srvpubsub.MakeGetStreamOpts
err := client.PubSub().MapStreamUnlimited(ctx, "channel_id", options(), &data)
Map a DataStore Stream first
options := srvpubsub.MakeGetStreamOpts
data := struct{}{}
err := client.PubSub().GetStreamFirst(ctx, "channel_id", options(), &data)
Delete DataStore Objects
httpResponse, err := client.PubSub().DeleteDataByChannel(ctx, "channel_id")
Delete a DataStore Object
httpResponse, err := client.PubSub().DeleteObject(ctx, "channel_id", "object_id")

Messaging API

interface
NewMessaging(string, enum.MessagingMode, enum.PackerFormat) *srvpubsub.CiosMessaging
PublishMessage(ciosctx.RequestCtx, string, interface{}, *string) (*_nethttp.Response, error)
PublishMessagePackerOnly(ciosctx.RequestCtx, string, interface{}) (*_nethttp.Response, error)
PublishMessageJSON(ciosctx.RequestCtx, string, cios.PackerFormatJson) (*_nethttp.Response, error)
Usage
Publish Message

※ Fix in the future

packerFormat := "payload_only"
data := struct{}{}
httpResponse, err := client.PubSub().PublishMessage(ctx, "channel_id", data, &packetFormat)
Publish payload only format

※ Fix in the future

data := struct{}{}
httpResponse, err := client.PubSub().PublishMessagePackerOnly(ctx, "channel_id", data)
Publish json format
data := struct{}{}
httpResponse, err := client.PubSub().PublishMessageJSON(ctx, "channel_id", data)
Create Messaging instance
ms := client.PubSub().NewMessaging("channel_id", enum.PubSub, enum.Json)
err := ms.Start(ctx)
...
ms.Close()
About Messaging Instance

※ Fix in the future

What doesn't exist interface yet.

  • Send a Message

    Send(message []byte) (err error)
    SendStr(message string) error
    SendAny(message interface{}) error
    SendJson(message interface{}) error
    Publish(message interface{}) error
    
    err := ms.Send([]byte{})
    err := ms.SendStr("sample")
    err := ms.SendJson(struct{}{})
    
  • Receive a Message

    Receive() (body []byte, err error)
    ReceiveStr() (string, error)
    MapReceived(stct interface{})
    
    byts, err := ms.Receive()
    str, err := ms.ReceiveStr()
    data struct{}
    err := ms.MapReceived(&data)
    

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateCiosWsConn

func CreateCiosWsConn(isDebug bool, url, authorization string) (connection *websocket.Conn, err error)

func CreateCiosWsMessagingURL

func CreateCiosWsMessagingURL(httpUrl, channelID, mode string, packerFormat *string) string

func MakeGetChannelsOpts

func MakeGetChannelsOpts() cios.ApiGetChannelsRequest

func MakeGetDataStoreChannelsOpts

func MakeGetDataStoreChannelsOpts() cios.ApiGetDataStoreChannelsRequest

func MakeGetObjectsOpts

func MakeGetObjectsOpts() cios.ApiGetDataStoreObjectsRequest

func MakeGetStreamOpts

func MakeGetStreamOpts() sdkmodel.ApiGetStreamRequest

Types

type CiosMessaging

type CiosMessaging struct {
	SubscribeFunc func([]byte) (bool, error)
	CloseFunc     func()
	Connection    *websocket.Conn
	// contains filtered or unexported fields
}

func (*CiosMessaging) Close

func (self *CiosMessaging) Close() (err error)

func (*CiosMessaging) MapReceived

func (self *CiosMessaging) MapReceived(stct interface{}) error

func (*CiosMessaging) OnClose

func (self *CiosMessaging) OnClose(arg func())

func (*CiosMessaging) OnReceive

func (self *CiosMessaging) OnReceive(arg func([]byte) (bool, error)) error

func (*CiosMessaging) Publish

func (self *CiosMessaging) Publish(message interface{}) error

func (*CiosMessaging) Receive

func (self *CiosMessaging) Receive() (body []byte, err error)

func (*CiosMessaging) ReceiveStr

func (self *CiosMessaging) ReceiveStr() (string, error)

func (*CiosMessaging) Send

func (self *CiosMessaging) Send(message []byte) (err error)

func (*CiosMessaging) SendAny

func (self *CiosMessaging) SendAny(message interface{}) error

func (*CiosMessaging) SendJson

func (self *CiosMessaging) SendJson(message interface{}) error

func (*CiosMessaging) SendStr

func (self *CiosMessaging) SendStr(message string) error

func (*CiosMessaging) SetReadTimeout

func (self *CiosMessaging) SetReadTimeout(t time.Duration) *CiosMessaging

func (*CiosMessaging) SetWriteTimeout

func (self *CiosMessaging) SetWriteTimeout(t time.Duration) *CiosMessaging

func (*CiosMessaging) Start

func (self *CiosMessaging) Start(ctx ciosctx.RequestCtx) (err error)

type CiosPubSub

type CiosPubSub struct {
	ApiClient *cios.APIClient
	Url       string
	Host      string
	// contains filtered or unexported fields
}

func NewCiosPubSub

func NewCiosPubSub(apiClient *cios.APIClient, url string, withHost func(context.Context) context.Context) *CiosPubSub

func (*CiosPubSub) ConnectWebSocket deprecated

func (self *CiosPubSub) ConnectWebSocket(channelID string, done chan bool, params ConnectWebSocketOptions) (err error)

Deprecated: should not be used

func (*CiosPubSub) CreateCIOSWebsocketConnection deprecated

func (self *CiosPubSub) CreateCIOSWebsocketConnection(url string, authorization string) (connection *websocket.Conn, err error)

Deprecated: should not be used

func (*CiosPubSub) CreateChannel

func (self *CiosPubSub) CreateChannel(ctx ciosctx.RequestCtx, body cios.ChannelProposal) (cios.Channel, *_nethttp.Response, error)

func (*CiosPubSub) CreateMessagingURL deprecated

func (self *CiosPubSub) CreateMessagingURL(channelID string, mode string, packerFormat *string) string

Deprecated: should not be used

func (*CiosPubSub) DeleteChannel

func (self *CiosPubSub) DeleteChannel(ctx ciosctx.RequestCtx, channelID string) (*_nethttp.Response, error)

func (*CiosPubSub) DeleteDataByChannel

func (self *CiosPubSub) DeleteDataByChannel(ctx ciosctx.RequestCtx, channelID string) (*_nethttp.Response, error)

func (*CiosPubSub) DeleteObject

func (self *CiosPubSub) DeleteObject(ctx ciosctx.RequestCtx, channelID string, objectID string) (*_nethttp.Response, error)

func (*CiosPubSub) GetChannel

func (self *CiosPubSub) GetChannel(ctx ciosctx.RequestCtx, channelID string, isDev *bool, lang *string) (cios.Channel, *_nethttp.Response, error)

func (*CiosPubSub) GetChannelFirst

func (self *CiosPubSub) GetChannelFirst(ctx ciosctx.RequestCtx, params cios.ApiGetChannelsRequest) (cios.Channel, *_nethttp.Response, error)

func (*CiosPubSub) GetChannels

func (self *CiosPubSub) GetChannels(ctx ciosctx.RequestCtx, params cios.ApiGetChannelsRequest) (response cios.MultipleChannel, httpResponse *_nethttp.Response, err error)

func (*CiosPubSub) GetChannelsAll

func (self *CiosPubSub) GetChannelsAll(ctx ciosctx.RequestCtx, params cios.ApiGetChannelsRequest) ([]cios.Channel, *_nethttp.Response, error)

func (*CiosPubSub) GetChannelsMapByID

func (self *CiosPubSub) GetChannelsMapByID(ctx ciosctx.RequestCtx, params cios.ApiGetChannelsRequest) (map[string]cios.Channel, *_nethttp.Response, error)

func (*CiosPubSub) GetChannelsMapByResourceOwnerID

func (self *CiosPubSub) GetChannelsMapByResourceOwnerID(ctx ciosctx.RequestCtx, params cios.ApiGetChannelsRequest) (map[string][]cios.Channel, *_nethttp.Response, error)

func (*CiosPubSub) GetChannelsUnlimited

func (self *CiosPubSub) GetChannelsUnlimited(ctx ciosctx.RequestCtx, params cios.ApiGetChannelsRequest) ([]cios.Channel, *_nethttp.Response, error)

func (*CiosPubSub) GetDataStoreChannel

func (self *CiosPubSub) GetDataStoreChannel(ctx ciosctx.RequestCtx, channelID string) (cios.DataStoreChannel, *_nethttp.Response, error)

func (*CiosPubSub) GetDataStoreChannels

func (self *CiosPubSub) GetDataStoreChannels(ctx ciosctx.RequestCtx, params cios.ApiGetDataStoreChannelsRequest) (response cios.MultipleDataStoreChannel, httpResponse *_nethttp.Response, err error)

func (*CiosPubSub) GetJsonStreamUnlimited

func (self *CiosPubSub) GetJsonStreamUnlimited(ctx ciosctx.RequestCtx, channelID string, params sdkmodel.ApiGetStreamRequest) (result []cios.PackerFormatJson, err error)

func (*CiosPubSub) GetMultiObjectLatest

func (self *CiosPubSub) GetMultiObjectLatest(ctx ciosctx.RequestCtx, channelIDs []string) (cios.MultipleDataStoreDataLatest, *_nethttp.Response, error)

func (*CiosPubSub) GetMultiObjectLatestByChannels

func (self *CiosPubSub) GetMultiObjectLatestByChannels(ctx ciosctx.RequestCtx, channels []cios.Channel) (cios.MultipleDataStoreDataLatest, *_nethttp.Response, error)

func (*CiosPubSub) GetObject

func (self *CiosPubSub) GetObject(ctx ciosctx.RequestCtx, channelID string, objectID string, packerFormat *string) (interface{}, *_nethttp.Response, error)

func (*CiosPubSub) GetObjectLatest

func (self *CiosPubSub) GetObjectLatest(ctx ciosctx.RequestCtx, channelID string, packerFormat *string) (interface{}, *_nethttp.Response, error)

func (*CiosPubSub) GetObjects

func (self *CiosPubSub) GetObjects(ctx ciosctx.RequestCtx, channelID string, params cios.ApiGetDataStoreObjectsRequest) (response cios.MultipleDataStoreObject, httpResponse *_nethttp.Response, err error)

func (*CiosPubSub) GetObjectsAll

func (*CiosPubSub) GetObjectsUnlimited

func (self *CiosPubSub) GetObjectsUnlimited(ctx ciosctx.RequestCtx, channelID string, params cios.ApiGetDataStoreObjectsRequest) ([]cios.DataStoreObject, *_nethttp.Response, error)

func (*CiosPubSub) GetOrCreateChannel

func (self *CiosPubSub) GetOrCreateChannel(ctx ciosctx.RequestCtx, params cios.ApiGetChannelsRequest, body cios.ChannelProposal) (cios.Channel, *_nethttp.Response, error)

func (*CiosPubSub) GetStream

func (self *CiosPubSub) GetStream(ctx ciosctx.RequestCtx, channelID string, params sdkmodel.ApiGetStreamRequest) ([]string, error)

func (*CiosPubSub) GetStreamAll

func (self *CiosPubSub) GetStreamAll(ctx ciosctx.RequestCtx, channelID string, params sdkmodel.ApiGetStreamRequest) ([]string, error)

func (*CiosPubSub) GetStreamFirst

func (self *CiosPubSub) GetStreamFirst(ctx ciosctx.RequestCtx, channelID string, params sdkmodel.ApiGetStreamRequest) (string, error)

func (*CiosPubSub) GetStreamUnlimited

func (self *CiosPubSub) GetStreamUnlimited(ctx ciosctx.RequestCtx, channelID string, params sdkmodel.ApiGetStreamRequest) ([]string, error)

func (*CiosPubSub) MapMultiObjectLatestPayload

func (self *CiosPubSub) MapMultiObjectLatestPayload(ctx ciosctx.RequestCtx, channelIDs []string, stc interface{}) ([]cios.PackerFormatJsonHeader, *_nethttp.Response, error)

func (*CiosPubSub) MapMultiObjectLatestPayloadByChannels

func (self *CiosPubSub) MapMultiObjectLatestPayloadByChannels(ctx ciosctx.RequestCtx, channels []cios.Channel, stc interface{}) ([]cios.PackerFormatJsonHeader, *_nethttp.Response, error)

func (*CiosPubSub) MapObjectLatest

func (self *CiosPubSub) MapObjectLatest(ctx ciosctx.RequestCtx, channelID string, packerFormat *string, stc interface{}) (*_nethttp.Response, error)

func (*CiosPubSub) MapStreamAll

func (self *CiosPubSub) MapStreamAll(ctx ciosctx.RequestCtx, channelID string, params sdkmodel.ApiGetStreamRequest, stc interface{}) error

func (*CiosPubSub) MapStreamFirst

func (self *CiosPubSub) MapStreamFirst(ctx ciosctx.RequestCtx, channelID string, params sdkmodel.ApiGetStreamRequest, stc interface{}) error

func (*CiosPubSub) MapStreamUnlimited

func (self *CiosPubSub) MapStreamUnlimited(ctx ciosctx.RequestCtx, channelID string, params sdkmodel.ApiGetStreamRequest, stc interface{}) error

func (*CiosPubSub) NewMessaging

func (self *CiosPubSub) NewMessaging(channelId string, mode enum.MessagingMode, packerFormat enum.PackerFormat) *CiosMessaging

func (*CiosPubSub) PublishMessage

func (self *CiosPubSub) PublishMessage(ctx ciosctx.RequestCtx, id string, body interface{}, packerFormat *string) (*_nethttp.Response, error)

func (*CiosPubSub) PublishMessageJSON

func (self *CiosPubSub) PublishMessageJSON(ctx ciosctx.RequestCtx, id string, body cios.PackerFormatJson) (*_nethttp.Response, error)

func (*CiosPubSub) PublishMessagePackerOnly

func (self *CiosPubSub) PublishMessagePackerOnly(ctx ciosctx.RequestCtx, id string, body interface{}) (*_nethttp.Response, error)

func (*CiosPubSub) SetDebug

func (self *CiosPubSub) SetDebug(isDebug bool)

func (*CiosPubSub) SetRefresh

func (self *CiosPubSub) SetRefresh(refresh func() error)

func (*CiosPubSub) SetToken

func (self *CiosPubSub) SetToken(token string)

func (*CiosPubSub) SetWsReadTimeout

func (self *CiosPubSub) SetWsReadTimeout(wsReadTimeout int64)

func (*CiosPubSub) SetWsWriteTimeout

func (self *CiosPubSub) SetWsWriteTimeout(wsWriteTimeout int64)

func (*CiosPubSub) UpdateChannel

func (self *CiosPubSub) UpdateChannel(ctx ciosctx.RequestCtx, channelID string, body cios.ChannelUpdateProposal) (cios.MultipleChannel, *_nethttp.Response, error)

type ConnectWebSocketOptions deprecated

type ConnectWebSocketOptions struct {
	PackerFormat  *string
	SubscribeFunc *func(body []byte) (bool, error)
	PublishStr    *chan *string
	Setting       *func(*websocket.Conn)
	Context       ciosctx.RequestCtx
}

Deprecated: should not be used

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL