Skip to content

Commit

Permalink
renamed broadcast feature to wildcard, more adequate with the way it …
Browse files Browse the repository at this point in the history
…works
  • Loading branch information
wandenberg committed Nov 9, 2013
1 parent 2391ddb commit 93fe74e
Show file tree
Hide file tree
Showing 23 changed files with 165 additions and 155 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.textile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
h1(#changelog). Changelog

* Renamed broadcast feature to wildcard, more adequate with the way it works
** push_stream_broadcast_channel_prefix -> push_stream_wildcard_channel_prefix
** push_stream_broadcast_channel_max_qtd -> push_stream_wildcard_channel_max_qtd
** push_stream_max_number_of_broadcast_channels -> push_stream_max_number_of_wildcard_channels
* Removed push_stream_content_type directive, use default_type Nginx directive to set the value, except on JSONP and Event Source modes
* Removed push_stream_keepalive directive, let Nginx decide when to use keepalive and how many requests accept using keepalive_* directives
* Removed push_stream_shared_memory_cleanup_objects_ttl directive
Expand Down
12 changes: 6 additions & 6 deletions README.textile
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ h1(#directives). Directives
| "push_stream_max_messages_stored_per_channel":push_stream_max_messages_stored_per_channel |   - |   x |   - |   - |   - |   - |
| "push_stream_max_channel_id_length":push_stream_max_channel_id_length |   - |   x |   - |   - |   - |   - |
| "push_stream_max_number_of_channels":push_stream_max_number_of_channels |   - |   x |   - |   - |   - |   - |
| "push_stream_max_number_of_broadcast_channels":push_stream_max_number_of_broadcast_channels |   - |   x |   - |   - |   - |   - |
| "push_stream_broadcast_channel_prefix":push_stream_broadcast_channel_prefix |   - |   x |   - |   - |   - |   - |
| "push_stream_max_number_of_wildcard_channels":push_stream_max_number_of_wildcard_channels |   - |   x |   - |   - |   - |   - |
| "push_stream_wildcard_channel_prefix":push_stream_wildcard_channel_prefix |   - |   x |   - |   - |   - |   - |
| "push_stream_channel_id":push_stream_channel_id |   - |   - |   - |   - |   - |   x |
| "push_stream_channels_path":push_stream_channels_path |   - |   - |   x |   x |   x |   - |
| "push_stream_authorized_channels_only":push_stream_authorized_channels_only |   - |   - |   x |   - |   - |   x |
| "push_stream_header_template":push_stream_header_template |   - |   - |   x |   - |   - |   x |
| "push_stream_message_template":push_stream_message_template |   - |   - |   x |   - |   - |   x |
| "push_stream_footer_template":push_stream_footer_template |   - |   - |   x |   - |   - |   x |
| "push_stream_broadcast_channel_max_qtd":push_stream_broadcast_channel_max_qtd |   - |   - |   x |   - |   - |   x |
| "push_stream_wildcard_channel_max_qtd":push_stream_wildcard_channel_max_qtd |   - |   - |   x |   - |   - |   x |
| "push_stream_ping_message_interval":push_stream_ping_message_interval |   - |   - |   x |   - |   - |   x |
| "push_stream_subscriber_connection_ttl":push_stream_subscriber_connection_ttl |   - |   - |   x |   - |   - |   x |
| "push_stream_longpolling_connection_ttl":push_stream_longpolling_connection_ttl |   - |   - |   x |   - |   - |   - |
Expand Down Expand Up @@ -217,15 +217,15 @@ h1(#contributors). Contributors
[push_stream_max_messages_stored_per_channel]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/main.textile#push_stream_max_messages_stored_per_channel
[push_stream_max_channel_id_length]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/main.textile#push_stream_max_channel_id_length
[push_stream_max_number_of_channels]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/main.textile#push_stream_max_number_of_channels
[push_stream_max_number_of_broadcast_channels]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/main.textile#push_stream_max_number_of_broadcast_channels
[push_stream_broadcast_channel_prefix]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/main.textile#push_stream_broadcast_channel_prefix
[push_stream_max_number_of_wildcard_channels]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/main.textile#push_stream_max_number_of_wildcard_channels
[push_stream_wildcard_channel_prefix]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/main.textile#push_stream_wildcard_channel_prefix
[push_stream_channel_id]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/publishers.textile#push_stream_channel_id
[push_stream_channels_path]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/subscribers.textile#push_stream_channels_path
[push_stream_authorized_channels_only]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/subscribers.textile#push_stream_authorized_channels_only
[push_stream_header_template]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/subscribers.textile#push_stream_header_template
[push_stream_message_template]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/subscribers.textile#push_stream_message_template
[push_stream_footer_template]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/subscribers.textile#push_stream_footer_template
[push_stream_broadcast_channel_max_qtd]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/subscribers.textile#push_stream_broadcast_channel_max_qtd
[push_stream_wildcard_channel_max_qtd]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/subscribers.textile#push_stream_wildcard_channel_max_qtd
[push_stream_ping_message_interval]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/subscribers.textile#push_stream_ping_message_interval
[push_stream_subscriber_connection_ttl]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/subscribers.textile#push_stream_subscriber_connection_ttl
[push_stream_longpolling_connection_ttl]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/subscribers.textile#push_stream_longpolling_connection_ttl
Expand Down
16 changes: 10 additions & 6 deletions docs/directives/main.textile
Original file line number Diff line number Diff line change
Expand Up @@ -109,23 +109,27 @@ h2(#push_stream_max_number_of_channels). push_stream_max_number_of_channels <a n
The maximum number of concurrent channels on the server. If you do not want to limit the number of channels, just not set this directive.


h2(#push_stream_max_number_of_broadcast_channels). push_stream_max_number_of_broadcast_channels <a name="push_stream_max_number_of_broadcast_channels" href="#">&nbsp;</a>
h2(#push_stream_max_number_of_wildcard_channels). push_stream_max_number_of_wildcard_channels <a name="push_stream_max_number_of_wildcard_channels" href="#">&nbsp;</a>

*syntax:* _push_stream_max_number_of_broadcast_channels number_
*syntax:* _push_stream_max_number_of_wildcard_channels number_

*default:* _none_

*context:* _http_

The maximum number of concurrent broadcats channels on the server. If you do not want to limit the number of broadcast channels, just not set this directive.
The maximum number of concurrent wildcard channels on the server. If you do not want to limit the number of wildcard channels, just not set this directive.


h2(#push_stream_broadcast_channel_prefix). push_stream_broadcast_channel_prefix <a name="push_stream_broadcast_channel_prefix" href="#">&nbsp;</a>
h2(#push_stream_wildcard_channel_prefix). push_stream_wildcard_channel_prefix <a name="push_stream_wildcard_channel_prefix" href="#">&nbsp;</a>

*syntax:* _push_stream_broadcast_channel_prefix string_
*syntax:* _push_stream_wildcard_channel_prefix string_

*default:* _none_

*context:* _http_

The string prefix used to identify when a channel is a normal or broadcast channel, example: when you set this directive as "bd_", "bd_ch1" will be a broadcast channel
The string prefix used to identify a wildcard channel, example: when you set this directive as "bd_", "bd_ch1" will be a wildcard channel.
A wildcard channel is technically equals to a normal one. It is intended to be used when the "push_stream_authorized_channels_only":push_stream_authorized_channels_only is set to on.


[push_stream_authorized_channels_only]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/subscribers.textile#push_stream_authorized_channels_only
14 changes: 8 additions & 6 deletions docs/directives/subscribers.textile
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ h2(#push_stream_authorized_channels_only). push_stream_authorized_channels_only

*context:* _location (push_stream_subscriber)_

Whether or not a subscriber may create a channel by making a request to a push_stream_subscriber location. If set to on, a publisher must send a POST request before a subscriber can request messages on the channel. Otherwise, all subscriber requests to nonexistent channels will get a 403 Forbidden response.
This restriction is not applied to broadcast channels, but to subscribe to a broadcast channel is necessary to subscribe at least to one normal channel, and if this directive is set to on this channel has to be created before.
When set to on, subscribers can connect only to a channel with at least one stored message.
All subscriber requests to nonexistent channels or channels without stored messages will get a 403 Forbidden response.
This restriction is not applied to wildcard channels, but to connect to a wildcard channel is necessary to connect to at least one normal channel on the same request.


h2(#push_stream_header_template). push_stream_header_template <a name="push_stream_header_template" href="#">&nbsp;</a>
Expand Down Expand Up @@ -133,16 +134,16 @@ h2(#push_stream_footer_template). push_stream_footer_template <a name="push_stre
The text that will be sent to subscribers before connection is closed (channel deleted or subscriber timeout), except when long polling connections timed out.


h2(#push_stream_broadcast_channel_max_qtd). push_stream_broadcast_channel_max_qtd <a name="push_stream_broadcast_channel_max_qtd" href="#">&nbsp;</a>
h2(#push_stream_wildcard_channel_max_qtd). push_stream_wildcard_channel_max_qtd <a name="push_stream_wildcard_channel_max_qtd" href="#">&nbsp;</a>

*syntax:* _push_stream_broadcast_channel_max_qtd number_
*syntax:* _push_stream_wildcard_channel_max_qtd number_

*default:* _none_

*context:* _location (push_stream_subscriber)_

The maximum number of broadcast channels that a subscriber may sign on the request.
This directive works in conjunction with push_stream_authorized_channels_only to preserve the server from a kind of attack where a subscriber sign one normal channel and many nonexistent broadcast channels.
The maximum number of wildcard channels that a subscriber may sign on the request.
This directive works in conjunction with "push_stream_authorized_channels_only":push_stream_authorized_channels_only to preserve the server from a kind of attack where a subscriber sign one normal channel and many nonexistent wildcard channels.


h2(#push_stream_ping_message_interval). push_stream_ping_message_interval <a name="push_stream_ping_message_interval" href="#">&nbsp;</a>
Expand Down Expand Up @@ -260,3 +261,4 @@ h2(#push_stream_allowed_origins). push_stream_allowed_origins <a name="push_stre
Set the value used on the Access-Control-Allow-Origin header to allow cross domain requests by javascript.

[eventsource_ref]http://dev.w3.org/html5/eventsource/
[push_stream_authorized_channels_only]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/subscribers.textile#push_stream_authorized_channels_only
12 changes: 6 additions & 6 deletions include/ngx_http_push_stream_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ typedef struct {
time_t channel_inactivity_time;
ngx_str_t ping_message_text;
ngx_uint_t qtd_templates;
ngx_str_t broadcast_channel_prefix;
ngx_str_t wildcard_channel_prefix;
ngx_uint_t max_number_of_channels;
ngx_uint_t max_number_of_broadcast_channels;
ngx_uint_t max_number_of_wildcard_channels;
time_t message_ttl;
ngx_uint_t max_subscribers_per_channel;
ngx_uint_t max_messages_stored_per_channel;
Expand All @@ -74,7 +74,7 @@ typedef struct {
ngx_str_t message_template;
ngx_int_t message_template_index;
ngx_str_t footer_template;
ngx_uint_t broadcast_channel_max_qtd;
ngx_uint_t wildcard_channel_max_qtd;
ngx_uint_t location_type;
ngx_msec_t ping_message_interval;
ngx_msec_t subscriber_connection_ttl;
Expand Down Expand Up @@ -134,7 +134,7 @@ typedef struct {
time_t last_activity_time;
time_t expires;
ngx_flag_t deleted;
ngx_flag_t broadcast;
ngx_flag_t wildcard;
ngx_http_push_stream_msg_t *channel_deleted_message;
} ngx_http_push_stream_channel_t;

Expand Down Expand Up @@ -195,7 +195,7 @@ typedef struct {
typedef struct {
ngx_rbtree_t tree;
ngx_uint_t channels; // # of channels being used
ngx_uint_t broadcast_channels; // # of broadcast channels being used
ngx_uint_t wildcard_channels; // # of wildcard channels being used
ngx_uint_t published_messages; // # of published messagens in all channels
ngx_uint_t stored_messages; // # of messages being stored
ngx_uint_t subscribers; // # of subscribers in all channels
Expand Down Expand Up @@ -232,7 +232,7 @@ static const ngx_str_t NGX_HTTP_PUSH_STREAM_NO_CHANNEL_ID_MESSAGE = ngx_string(
static const ngx_str_t NGX_HTTP_PUSH_STREAM_NO_CHANNEL_ID_NOT_AUTHORIZED_MESSAGE = ngx_string("Channel id not authorized for this method.");
static const ngx_str_t NGX_HTTP_PUSH_STREAM_EMPTY_POST_REQUEST_MESSAGE = ngx_string("Empty post requests are not allowed.");
static const ngx_str_t NGX_HTTP_PUSH_STREAM_TOO_LARGE_CHANNEL_ID_MESSAGE = ngx_string("Channel id is too large.");
static const ngx_str_t NGX_HTTP_PUSH_STREAM_TOO_MUCH_BROADCAST_CHANNELS = ngx_string("Subscribed too much broadcast channels.");
static const ngx_str_t NGX_HTTP_PUSH_STREAM_TOO_MUCH_WILDCARD_CHANNELS = ngx_string("Subscribed too much wildcard channels.");
static const ngx_str_t NGX_HTTP_PUSH_STREAM_TOO_SUBSCRIBERS_PER_CHANNEL = ngx_string("Subscribers limit per channel has been exceeded.");
static const ngx_str_t NGX_HTTP_PUSH_STREAM_CANNOT_CREATE_CHANNELS = ngx_string("Subscriber could not create channels.");
static const ngx_str_t NGX_HTTP_PUSH_STREAM_NUMBER_OF_CHANNELS_EXCEEDED_MESSAGE = ngx_string("Number of channels were exceeded.");
Expand Down
2 changes: 1 addition & 1 deletion include/ngx_http_push_stream_module_ipc.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ ngx_socket_t ngx_http_push_stream_socketpairs[NGX_MAX_PROCESSES][2];

static ngx_int_t ngx_http_push_stream_register_worker_message_handler(ngx_cycle_t *cycle);

static void ngx_http_push_stream_broadcast(ngx_http_push_stream_channel_t *channel, ngx_http_push_stream_msg_t *msg, ngx_log_t *log);
static void ngx_http_push_stream_wildcard(ngx_http_push_stream_channel_t *channel, ngx_http_push_stream_msg_t *msg, ngx_log_t *log);

static ngx_int_t ngx_http_push_stream_alert_worker(ngx_pid_t pid, ngx_int_t slot, ngx_log_t *log, ngx_channel_t command);
#define ngx_http_push_stream_alert_worker_check_messages(pid, slot, log) ngx_http_push_stream_alert_worker(pid, slot, log, NGX_CMD_HTTP_PUSH_STREAM_CHECK_MESSAGES)
Expand Down
2 changes: 1 addition & 1 deletion include/ngx_http_push_stream_module_setup.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static time_t NGX_HTTP_PUSH_STREAM_DEFAULT_CHANNEL_INACTIVITY_TIME = 30;

#define NGX_HTTP_PUSH_STREAM_DEFAULT_PADDING_BY_USER_AGENT "[A|a]ndroid 2,4097,4097:[S|s]afari,1025,0"

#define NGX_HTTP_PUSH_STREAM_DEFAULT_BROADCAST_CHANNEL_PREFIX ""
#define NGX_HTTP_PUSH_STREAM_DEFAULT_WILDCARD_CHANNEL_PREFIX ""

static char * ngx_http_push_stream_channels_statistics(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);

Expand Down
Loading

0 comments on commit 93fe74e

Please sign in to comment.