class Capsium::Reactor::Introspection
Monitoring HTTP API reports for the packages this reactor serves (ARCHITECTURE.md section 7): the package-level /api/v1/introspect/* endpoints aggregate ALL mounted packages, the 07-reactor follow-ons add reactor-level /introspect/* (status, config, metrics) and per-package /package/:id/* (status, metadata, logs) resolved by package name.
Constants
- CONFIG_PATH
- CONTENT_HASHES_PATH
- CONTENT_VALIDITY_PATH
- DEFAULT_LOG_LINES
- MAX_LOG_LINES
- METADATA_PATH
- METRICS_PATH
- PACKAGE_MOUNT
-
Per-package endpoints: “/package/<name>/status|metadata|logs”.
PACKAGE_MOUNTis the mount point (WEBricklongest-prefix matching routes all “/package/…” requests to the reactor); the name resolves against every mounted package, anything else is a 404. - PACKAGE_PATH_PATTERN
- PATHS
- REACTOR_PATHS
- ROUTES_PATH
- STATUS_PATH
Attributes
Array[Package]
Public Class Methods
(Array[Package] packages, ?reactor: Reactor? reactor) → void
Source
# File lib/capsium/reactor/introspection.rb, line 43 def initialize(packages, reactor: nil) @packages = packages @reactor = reactor end
The packages this reactor serves (one per mount; ARCHITECTURE.md section 7 introspection aggregates all of them).
Public Instance Methods
() → Hash[Symbol, untyped]
Source
# File lib/capsium/reactor/introspection.rb, line 102 def config_report { port: @reactor.port, storeDir: store_dir, cacheControl: @reactor.cache_control, authEnabled: @reactor.authenticator.enabled?, registry: registry_location } end
Reactor configuration; secrets (deploy.json, registry URL credentials) are never exposed.
() → Hash[Symbol, untyped]
Source
# File lib/capsium/reactor/introspection.rb, line 85 def content_hashes_report entries = @packages.map do |pkg| { package: pkg.name, hash: content_hash(pkg) } end { contentHashes: entries } end
() → Hash[Symbol, untyped]
Source
# File lib/capsium/reactor/introspection.rb, line 92 def content_validity_report { contentValidity: @packages.map { |pkg| content_validity_entry(pkg) } } end
(String path) → bool
Source
# File lib/capsium/reactor/introspection.rb, line 51 def endpoint?(path) PATHS.include?(path) || package_endpoint?(path) || (!@reactor.nil? && REACTOR_PATHS.include?(path)) end
() → Hash[Symbol, untyped]
Source
# File lib/capsium/reactor/introspection.rb, line 71 def metadata_report { packages: @packages.map { |pkg| metadata_entry(pkg) } } end
() → Hash[Symbol, untyped]
Source
# File lib/capsium/reactor/introspection.rb, line 112 def metrics_report = @reactor.metrics.snapshot.merge(uptime: uptime)
() → Package
Source
# File lib/capsium/reactor/introspection.rb, line 49 def package = @packages.first
The first mounted package (the single-package view).
(String path, ?params: Hash[String, String] params) → Hash[Symbol, untyped]?
Source
# File lib/capsium/reactor/introspection.rb, line 58 def report_for(path, params: {}) case path when METADATA_PATH then metadata_report when ROUTES_PATH then routes_report when CONTENT_HASHES_PATH then content_hashes_report when CONTENT_VALIDITY_PATH then content_validity_report when STATUS_PATH then status_report when CONFIG_PATH then config_report when METRICS_PATH then metrics_report else package_report_for(path, params) end end
The report body for an endpoint, or nil when the path is not an endpoint or the package name does not match (404).
() → Hash[Symbol, untyped]
Source
# File lib/capsium/reactor/introspection.rb, line 75 def routes_report entries = @packages.map do |pkg| routes = pkg.routes.config.routes.map do |route| { method: route.http_method || "GET", path: route.path } end { package: pkg.name, routes: routes } end { routes: entries } end
() → Hash[Symbol, untyped]
Source
# File lib/capsium/reactor/introspection.rb, line 96 def status_report { status: "running", uptime: uptime, packagesLoaded: @packages.size } end