Go V4 Channel Groups API Reference for Realtime Apps
Channel Groups allows PubNub developers to bundle thousands of channels into a group that can be identified by name. These Channel Groups can then be subscribed to, receiving data from the many backend-channels the channel group contains.
Learn more about our Channel Groups here.
Adding Channels
Requires Stream Controller add-onRequires that the Stream Controller add-on is enabled for your key. See this page on enabling add-on features on your keys:
https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-
Description
This function adds a channel to a channel group.
Method(s)
Adding Channels
is accomplished by using the following method(s) in the Go V4 SDK:
Note
200 channels
can be added to the channel group
per API call.
pn.AddChannelToChannelGroup().Channels([]string).ChannelGroup(string).QueryParam(queryParam).Execute()
Parameter Type Required Description Channels
[]string Yes channels
to add to the channel groupChannelGroup
string Yes The channel group
to add the channels to.QueryParam
map[string]string Optional QueryParam 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
pn.AddChannelToChannelGroup().
Channels([]string{"ch1", "ch2"}).
ChannelGroup("cg").
Execute()
Response
{
"service" : "channel-registry",
"status" : 200,
"error" : false,
"message" : "OK"
}
Listing Channels
Requires Stream Controller add-onRequires that the Stream Controller add-on is enabled for your key. See this page on enabling add-on features on your keys:
https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-
Description
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 V4 SDK:
pn.ListChannelsInChannelGroup().ChannelGroup(string).QueryParam(queryParam).Execute()
Parameter Type Required Description ChannelGroup
string Yes The channel group
to fetch channels.QueryParam
map[string]string Optional QueryParam 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
pn.ListChannelsInChannelGroup().
ChannelGroup("cg").
Execute()
Response
Method | Type | Description |
---|---|---|
Channels | []string | Yes |
Group | string | Yes |
Removing Channels
Requires Stream Controller add-onRequires that the Stream Controller add-on is enabled for your key. See this page on enabling add-on features on your keys:
https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-
Description
This function removes the channels from the channel group.
Method(s)
Removing Channels
is accomplished by using the following method(s) in the Go V4 SDK:
pn.RemoveChannelFromChannelGroup().ChannelGroup(string).Channels([]string).QueryParam(queryParam).Execute()
Parameter Type Required Description Channels
[]string Yes channels
remove from the channel group.ChannelGroup
string Yes The channel group
to remove the channels from.QueryParam
map[string]string Optional QueryParam 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
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
}
AffectedChannels:[]
AffectedChannelGroups:[]
}
Deleting Channel Group
Requires Stream Controller add-onRequires that the Stream Controller add-on is enabled for your key. See this page on enabling add-on features on your keys:
https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-
Description
This function removes the channel group.
Method(s)
Deleting Channel Group
is accomplished by using the following method(s) in the Go V4 SDK:
pn.DeleteChannelGroup().ChannelGroup(string).QueryParam(queryParam).Execute()
Parameter Type Required Description ChannelGroup
string Yes The channel group
to removeQueryParam
map[string]string Optional QueryParam 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
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
}
AffectedChannels:[]
AffectedChannelGroups:[]
}