Class: AnyCable::HealthServer
- Inherits:
-
Object
- Object
- AnyCable::HealthServer
- Defined in:
- lib/anycable/health_server.rb
Overview
Constant Summary collapse
- SUCCESS_RESPONSE =
[200, "Ready"].freeze
- FAILURE_RESPONSE =
[503, "Not Ready"].freeze
Instance Attribute Summary collapse
-
#grpc_server ⇒ Object
readonly
Returns the value of attribute grpc_server.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
Instance Method Summary collapse
-
#initialize(grpc_server, port:, path: "/health", logger: AnyCable.logger) ⇒ HealthServer
constructor
A new instance of HealthServer.
- #running? ⇒ Boolean
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(grpc_server, port:, path: "/health", logger: AnyCable.logger) ⇒ HealthServer
Returns a new instance of HealthServer.
26 27 28 29 30 31 32 |
# File 'lib/anycable/health_server.rb', line 26 def initialize(grpc_server, port:, path: "/health", logger: AnyCable.logger) @grpc_server = grpc_server @port = port @path = path @logger = logger @server = build_server end |
Instance Attribute Details
#grpc_server ⇒ Object (readonly)
Returns the value of attribute grpc_server.
24 25 26 |
# File 'lib/anycable/health_server.rb', line 24 def grpc_server @grpc_server end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
24 25 26 |
# File 'lib/anycable/health_server.rb', line 24 def path @path end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
24 25 26 |
# File 'lib/anycable/health_server.rb', line 24 def port @port end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
24 25 26 |
# File 'lib/anycable/health_server.rb', line 24 def server @server end |
Instance Method Details
#running? ⇒ Boolean
48 49 50 |
# File 'lib/anycable/health_server.rb', line 48 def running? server.status == :Running end |
#start ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/anycable/health_server.rb', line 34 def start return if running? Thread.new { server.start } logger.info "HTTP health server is listening on localhost:#{port} and mounted at \"#{path}\"" end |
#stop ⇒ Object
42 43 44 45 46 |
# File 'lib/anycable/health_server.rb', line 42 def stop return unless running? server.shutdown end |