Class: Rack::Heartbeat
- Inherits:
-
Object
- Object
- Rack::Heartbeat
- Defined in:
- lib/rack/heartbeat.rb
Overview
A heartbeat mechanism for the server. This will add a /heartbeat endpoint that returns status 200 and content OK when executed.
Defined Under Namespace
Classes: Railtie
Constant Summary collapse
- @@heartbeat_path =
'heartbeat'
Class Method Summary collapse
Instance Method Summary collapse
- #call(env) ⇒ Object
- #heartbeat_path ⇒ Object
-
#initialize(app) ⇒ Heartbeat
constructor
A new instance of Heartbeat.
Constructor Details
#initialize(app) ⇒ Heartbeat
Returns a new instance of Heartbeat.
18 19 20 |
# File 'lib/rack/heartbeat.rb', line 18 def initialize(app) @app = app end |
Class Method Details
.heartbeat_path ⇒ Object
9 10 11 |
# File 'lib/rack/heartbeat.rb', line 9 def heartbeat_path @@heartbeat_path end |
.heartbeat_path=(path) ⇒ Object
13 14 15 |
# File 'lib/rack/heartbeat.rb', line 13 def heartbeat_path=(path) @@heartbeat_path = path end |
.setup {|_self| ... } ⇒ Object
35 36 37 |
# File 'lib/rack/heartbeat.rb', line 35 def self.setup yield self end |
Instance Method Details
#call(env) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/rack/heartbeat.rb', line 22 def call(env) if env['PATH_INFO'] == "/#{heartbeat_path}" NewRelic::Agent.ignore_transaction if defined? NewRelic [200, {"Content-Type" => "text/plain"}, ["OK"]] else @app.call(env) end end |
#heartbeat_path ⇒ Object
31 32 33 |
# File 'lib/rack/heartbeat.rb', line 31 def heartbeat_path self.class.heartbeat_path end |