module Sinatra::RedisLogHelper
Public Instance Methods
capture_redis(stream, host = 'localhost', port = 6379, timeout = 30, command = 'MONITOR') { |data| ... }
click to toggle source
# File lib/sidekiq/redislog/redis_log_helper.rb, line 13 def capture_redis stream, host = 'localhost', port = 6379, timeout = 30, command = 'MONITOR' telnet_session = Net::Telnet::new("Host" => host, "Port" => port, "Timeout" => timeout) telnet_session.cmd(command) do |data| yield data if block_given? end telnet_session.close end
get_redis_config()
click to toggle source
# File lib/sidekiq/redislog/redis_log_helper.rb, line 26 def get_redis_config config = {:host => 'localhost', :port => 6379} Sidekiq.redis do |redis| config[:host] = redis.client.host config[:port] = redis.client.port end config end
set_sse_headers(response)
click to toggle source
# File lib/sidekiq/redislog/redis_log_helper.rb, line 3 def set_sse_headers response response.headers.delete('Content-Length') # no content length response.headers['X-Accel-Buffering'] = 'no' # for nginx response.headers["Connection"] = "keepalive" # optimisation response.headers["Cache-Control"] = "no-cache, no-store" # important for browsers response.headers['Last-Modified'] = Time.now.to_s # fixes buffering end