Skip to main content

Function: getMonitor()

getMonitor(type: "cdn-edge-consistency" | "dns" | "http" | "http-header" | "http-json" | "http-keyword" | "http-latency" | "http-status" | "ping" | "port" | "replication" | "server-heartbeat" | "ssl" | "websocket-keepalive", config?: MonitorServiceConfig, forceConfigUpdate?: boolean): IMonitorService

Defined in: electron/services/monitoring/MonitorFactory.ts:306

Retrieves the monitor service instance for a given monitor type, creating it if necessary.

Parameters

type

The monitor type string. Must be a valid registered type.

"cdn-edge-consistency" | "dns" | "http" | "http-header" | "http-json" | "http-keyword" | "http-latency" | "http-status" | "ping" | "port" | "replication" | "server-heartbeat" | "ssl" | "websocket-keepalive"

config?

MonitorServiceConfig

Optional monitor configuration to apply to the instance.

forceConfigUpdate?

boolean = false

If true, updates the configuration on an existing instance even if already set.

Returns

IMonitorService

The monitor service instance for the specified type.

Remarks

Validates the monitor type against the registry.

  • Uses the singleton pattern: returns the cached instance if available, otherwise creates a new one. - If a configuration is provided, updates the instance's configuration if forced or if the instance is new. - Throws if the monitor type is unsupported or if no factory is registered for the type.
  • Configuration failures are logged but do not prevent service retrieval.

Example

const monitor = getMonitor("http", { timeout: 5000 });

Throws

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error If the monitor type is not supported or no service factory is registered for the type.

Throws

MonitorConfigurationError If configuration application fails.

See