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 =
Default bind host for the observability server.
"0.0.0.0"- DEFAULT_PORT =
Default TCP port for the observability server.
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.
25 26 27 28 29 30 31 32 33 |
# File 'lib/mammoth/observability_server.rb', line 25 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.
18 19 20 |
# File 'lib/mammoth/observability_server.rb', line 18 def config @config end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
18 19 20 |
# File 'lib/mammoth/observability_server.rb', line 18 def host @host end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
18 19 20 |
# File 'lib/mammoth/observability_server.rb', line 18 def logger @logger end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
18 19 20 |
# File 'lib/mammoth/observability_server.rb', line 18 def port @port end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
18 19 20 |
# File 'lib/mammoth/observability_server.rb', line 18 def server @server end |
#sqlite_store ⇒ Object (readonly)
Returns the value of attribute sqlite_store.
18 19 20 |
# File 'lib/mammoth/observability_server.rb', line 18 def sqlite_store @sqlite_store end |
Instance Method Details
#shutdown ⇒ void
This method returns an undefined value.
Stop the HTTP server.
45 46 47 |
# File 'lib/mammoth/observability_server.rb', line 45 def shutdown server.shutdown end |
#start ⇒ void
This method returns an undefined value.
Start the blocking HTTP server.
38 39 40 |
# File 'lib/mammoth/observability_server.rb', line 38 def start server.start end |