Channel Groups API for PubNub Go SDK

Channel groups allow PubNub developers to bundle thousands of channels into a group that can be identified by a name. These channel groups can then be subscribed to, receiving data from the many back-end channels the channel group contains.

Channel group operations

You can't publish to a channel group. You can only subscribe to it. To publish within the channel group, you need to publish to each channel individually.

Add Channels

Requires Stream Controller add-on

This method requires that the Stream Controller add-on is enabled for your key in the Admin Portal. Read the support page on enabling add-on features on your keys.

This function adds a channel to a channel group.

Method(s)

Adding Channels is accomplished by using the following method(s) in the Go SDK:

Maximum number of channels

200 channels can be added to the channel group per API call.

pn.AddChannelToChannelGroup().
Channels([]string).
ChannelGroup(string).
QueryParam(queryParam).
Execute()
ParameterTypeRequiredDescription
Channels[]stringYeschannels to add to the channel group
ChannelGroupstringYesThe channel group to add the channels to.
QueryParammap[string]stringOptionalQueryParam accepts a map, the keys and values of the map are passed as the query string parameters of the URL called by the API.

Basic Usage

Add Channels

pn.AddChannelToChannelGroup().
Channels([]string{"ch1", "ch2"}).
ChannelGroup("cg").
Execute()

Response

{
"service" : "channel-registry",
"status" : 200,
"error" : false,
"message" : "OK"
}

List Channels

Requires Stream Controller add-on

This method requires that the Stream Controller add-on is enabled for your key in the Admin Portal. Read the support page on enabling add-on features on your keys.

This function lists all the channels of the channel group.

Method(s)

Listing Channels is accomplished by using the following method(s) in the Go SDK:

pn.ListChannelsInChannelGroup().
ChannelGroup(string).
QueryParam(queryParam).
Execute()
ParameterTypeRequiredDescription
ChannelGroupstringYesThe channel group to fetch channels.
QueryParammap[string]stringOptionalQueryParam accepts a map, the keys and values of the map are passed as the query string parameters of the URL called by the API.

Basic Usage

List Channels

pn.ListChannelsInChannelGroup().
ChannelGroup("cg").
Execute()

Response

MethodTypeDescription
Channels[]stringYes
GroupstringYes

Remove Channels

Requires Stream Controller add-on

This method requires that the Stream Controller add-on is enabled for your key in the Admin Portal. Read the support page on enabling add-on features on your keys.

This function removes the channels from the channel group.

Method(s)

Removing Channels is accomplished by using the following method(s) in the Go SDK:

pn.RemoveChannelFromChannelGroup().
ChannelGroup(string).
Channels([]string).
QueryParam(queryParam).
Execute()
ParameterTypeRequiredDescription
ChannelGroupstringYesThe channel group to remove the channels from.
Channels[]stringYeschannels remove from the channel group.
QueryParammap[string]stringOptionalQueryParam accepts a map, the keys and values of the map are passed as the query string parameters of the URL called by the API.

Basic Usage

Remove channels

pn.RemoveChannelFromChannelGroup().
ChannelGroup("cg").
Channels([]string{"ch1", "ch2"}).
Execute()

Response

{
Error:<nil>
Category:Unknown
Operation:Remove Channel From Channel Group
StatusCode:200
TLSEnabled:true
UUID:d9713e5a-6bcb-439a-942e-5ba064f2e5dd
AuthKey:
Origin:ps.pndsn.com
OriginalResponse: {
"status": 200,
"message": "OK",
"service": "channel-registry",
"error": false
}
show all 18 lines

Delete Channel Group

Requires Stream Controller add-on

This method requires that the Stream Controller add-on is enabled for your key in the Admin Portal. Read the support page on enabling add-on features on your keys.

This function removes the channel group.

Method(s)

Deleting Channel Group is accomplished by using the following method(s) in the Go SDK:

pn.DeleteChannelGroup().
ChannelGroup(string).
QueryParam(queryParam).
Execute()
ParameterTypeRequiredDescription
ChannelGroupstringYesThe channel group to remove
QueryParammap[string]stringOptionalQueryParam accepts a map, the keys and values of the map are passed as the query string parameters of the URL called by the API.

Basic Usage

Delete Channel Group

pn.DeleteChannelGroup().
ChannelGroup("remove-cg").
Execute()

Response

{
Error:<nil>
Category:Unknown
Operation:Remove Channel Group
StatusCode:200
TLSEnabled:true
UUID:650089a0-922c-4de6-b422-7a38a964bf45
AuthKey:
Origin:ps.pndsn.com
OriginalResponse: {
"status": 200,
"message": "OK",
"service": "channel-registry",
"error": false
}
show all 18 lines
Last updated on