Class: Firehose::Rack::Ping::PingCheck

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/firehose/rack/ping.rb

Overview

Encapsulate this in a class so we aren’t passing a bunch of variables around

Constant Summary collapse

TEST_VALUE =
'Firehose Healthcheck Test Value'
SECONDS_TO_EXPIRE =
60

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#response

Constructor Details

#initialize(env, redis = nil) ⇒ PingCheck

Returns a new instance of PingCheck.



33
34
35
36
37
38
# File 'lib/firehose/rack/ping.rb', line 33

def initialize(env, redis=nil)
  @redis = redis || self.class.redis
  @env   = env
  @req   = env['parsed_request'] ||= ::Rack::Request.new(env)
  @key   = "/firehose/ping/#{Time.now.to_i}/#{rand}"
end

Instance Attribute Details

#envObject (readonly)

Returns the value of attribute env.



24
25
26
# File 'lib/firehose/rack/ping.rb', line 24

def env
  @env
end

#keyObject (readonly)

Returns the value of attribute key.



24
25
26
# File 'lib/firehose/rack/ping.rb', line 24

def key
  @key
end

#redisObject (readonly)

Returns the value of attribute redis.



24
25
26
# File 'lib/firehose/rack/ping.rb', line 24

def redis
  @redis
end

#reqObject (readonly)

Returns the value of attribute req.



24
25
26
# File 'lib/firehose/rack/ping.rb', line 24

def req
  @req
end

Class Method Details

.redisObject



29
30
31
# File 'lib/firehose/rack/ping.rb', line 29

def self.redis
  @redis ||= Firehose::Server.redis.connection
end

Instance Method Details

#callObject



40
41
42
43
# File 'lib/firehose/rack/ping.rb', line 40

def call
  log req, 'started'
  test_redis
end