Class: Mammoth::ObservabilityServer
- Inherits:
-
Object
- Object
- Mammoth::ObservabilityServer
- Defined in:
- lib/mammoth/observability_server.rb
Overview
Small HTTP server exposing Mammoth health, readiness, and metrics endpoints.
The server is intentionally independent from the replication loop. Operators may run it as a sidecar-like process or in a separate process that points at the same SQLite operational database.
Constant Summary collapse
- DEFAULT_HOST =
"0.0.0.0"- DEFAULT_PORT =
9393
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
-
#sqlite_store ⇒ Object
readonly
Returns the value of attribute sqlite_store.
Instance Method Summary collapse
-
#initialize(config, host: nil, port: nil, sqlite_store: nil, logger: nil) ⇒ ObservabilityServer
constructor
A new instance of ObservabilityServer.
-
#shutdown ⇒ void
Stop the HTTP server.
-
#start ⇒ void
Start the blocking HTTP server.
Constructor Details
#initialize(config, host: nil, port: nil, sqlite_store: nil, logger: nil) ⇒ ObservabilityServer
Returns a new instance of ObservabilityServer.
23 24 25 26 27 28 29 30 31 |
# File 'lib/mammoth/observability_server.rb', line 23 def initialize(config, host: nil, port: nil, sqlite_store: nil, logger: nil) @config = config @host = host || config.dig("observability", "host") || DEFAULT_HOST @port = port || config.dig("observability", "port") || DEFAULT_PORT @sqlite_store = sqlite_store @logger = logger || WEBrick::Log.new($stderr, WEBrick::Log::WARN) @server = build_server mount_endpoints end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
16 17 18 |
# File 'lib/mammoth/observability_server.rb', line 16 def config @config end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
16 17 18 |
# File 'lib/mammoth/observability_server.rb', line 16 def host @host end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
16 17 18 |
# File 'lib/mammoth/observability_server.rb', line 16 def logger @logger end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
16 17 18 |
# File 'lib/mammoth/observability_server.rb', line 16 def port @port end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
16 17 18 |
# File 'lib/mammoth/observability_server.rb', line 16 def server @server end |
#sqlite_store ⇒ Object (readonly)
Returns the value of attribute sqlite_store.
16 17 18 |
# File 'lib/mammoth/observability_server.rb', line 16 def sqlite_store @sqlite_store end |
Instance Method Details
#shutdown ⇒ void
This method returns an undefined value.
Stop the HTTP server.
43 44 45 |
# File 'lib/mammoth/observability_server.rb', line 43 def shutdown server.shutdown end |
#start ⇒ void
This method returns an undefined value.
Start the blocking HTTP server.
36 37 38 |
# File 'lib/mammoth/observability_server.rb', line 36 def start server.start end |