Class: Redisse::Server Private
- Inherits:
-
Goliath::API
- Object
- Goliath::API
- Redisse::Server
- Includes:
- Redis, Responses
- Defined in:
- lib/redisse/server.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Goliath::API class that defines the server.
See #run.
Defined Under Namespace
Modules: Redis, Responses Classes: Stats
Constant Summary
- LONG_POLLING_DELAY =
Delay between receiving a message and closing the connection.
Closing the connection is necessary when using long polling, because the client is not able to read the data before the connection is closed. But instead of closing immediately, we delay a bit closing the connection to give a chance for several messages to be sent in a row.
1
- HEARTBEAT_PERIOD =
The period between heartbeats in seconds.
15
Instance Method Summary (collapse)
-
- (Server) initialize(redisse)
constructor
private
A new instance of Server.
- - (Object) on_close(env) private
- - (Object) options_parser(opts, options) private
- - (Object) response(env) private
Methods included from Redis
#ensure_pubsub, #on_redis_close, #pubsub, #pubsub_subcribe, #pubsub_unsubscribe_proc, #redis
Methods included from Responses
#not_acceptable, #not_found, #plain_response, #service_unavailable
Constructor Details
- (Server) initialize(redisse)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Server
61 62 63 64 |
# File 'lib/redisse/server.rb', line 61 def initialize(redisse) @redisse = redisse super() end |
Instance Method Details
- (Object) on_close(env)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
80 81 82 83 84 85 |
# File 'lib/redisse/server.rb', line 80 def on_close(env) env.status[:stats][:connected] -= 1 env.status[:stats][:served] += 1 unsubscribe(env) stop_heartbeat(env) end |
- (Object) options_parser(opts, options)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
195 196 197 198 199 200 201 202 |
# File 'lib/redisse/server.rb', line 195 def (opts, ) opts.on '--redis REDIS_URL', 'URL of the Redis connection' do |url| redisse.redis_server = url end default_port = redisse.default_port return unless default_port [:port] = default_port end |
- (Object) response(env)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/redisse/server.rb', line 66 def response(env) return not_acceptable unless acceptable?(env) channels = Array(redisse.channels(env)) return not_found if channels.empty? subscribe(env, channels) or return service_unavailable send_history_events(env, channels) heartbeat(env) streaming_response(200, { 'Content-Type' => 'text/event-stream', 'Cache-Control' => 'no-cache', 'X-Accel-Buffering' => 'no', }) end |