firehoseio / firehose

Build realtime Ruby web applications. Created by the fine folks at Poll Everywhere.
http://firehose.io/
MIT License
727 stars 72 forks source link

Configurable resource channel buffer sizes #35

Closed bradgessler closed 8 years ago

bradgessler commented 10 years ago

Firehose is currently hard-coded to hold 100 of the most recent publish messages per channel so that if a subscribes' connection drops, it can reconnect and receive the remaining messages. If a client is disconnected and 101 messages are published, a message will be dropped upon reconnection.

A 100 message buffer is not always desirable.

In many of cases the publisher concerned only about giving a client the latest representation of a resource that is published to Firehose; thus the buffer size should be 1. Then if a client connection drops for a few moments and 101 messages are published, 100 messages will be dropped and the client will simply get the most recent representation of that resource.

Firehose::Server::Publisher should accept the header X-Firehose-Buffer-Size: 1 where the X-Firehose-Buffer-Size number is greater than 1. Firehose should return a 400 Bad Request if a value less than 1 is specified.

The Firehose::Client::Publisher should emit the header X-Firehose-Buffer-Size: 10 when Firehose::Client::Publisher#publish(message, :buffer_size => 10).to('/my/resource') method is called.