nchan_channel_group
The nchan_channel_group directive defines a unique group identifier for related pub/sub message channels.
Description
The nchan_channel_group directive is used to associate channels within the Nchan pub/sub environment, enabling features such as message grouping, accounting, and limits on a per-group basis. By using a unique group identifier specified by this directive, you can manage different sets of channels easily, applying configuration options that are common to all channels within the group. This is particularly useful for applications that require logical separation of message flows, such as those by user type or feature set. When messages are published to or subscribed from channels belonging to the same group, Nchan utilizes this grouping to optimize resource use and performance, such as aggregation and shared configuration settings for channel behavior.
The directive is context-sensitive and can be placed within a server, location, or if in location blocks. Its single argument specifies the group name, which is a string value that acts as an identifier for the group of channels. If no group is defined, channels operate independently without shared configuration settings. This flexibility allows developers to create sophisticated pub/sub architectures by configuring grouping behavior across various channels dynamically, ensuring that resource allocation for subscribers can be handled more efficiently based on the logical relationships defined by the nchan_channel_group.
Config Example
location /pub {
nchan_channel_group user_messages;
nchan_pubsub;
}
location /sub {
nchan_channel_group user_messages;
nchan_subscriber_channel_id $arg_channel;
}
Using the directive in an incorrect context will cause NGINX to throw a configuration error.
Not specifying a group name can result in orphaned channels that do not share configurations.
If multiple groups are used improperly, it can lead to increased complexity in message handling and resource allocation.