Skip to main content

Class: MigrationOrchestrator

Defined in: electron/services/monitoring/MigrationSystem.ts:141

Orchestrates migration of monitor configuration data for a given monitor type.

Remarks

Applies registered migration rules in sequence to upgrade monitor data. Handles errors, warnings, and version updates. Used internally by the migration system and exposed via factory.

Constructors

Constructor

new MigrationOrchestrator(registry: MigrationRegistry, versionManager: VersionManager): MigrationOrchestrator

Defined in: electron/services/monitoring/MigrationSystem.ts:323

Constructs a new MigrationOrchestrator instance.

Parameters

registry

MigrationRegistry

The MigrationRegistry instance containing migration rules

versionManager

VersionManager

The VersionManager instance for tracking version state

Returns

MigrationOrchestrator

Remarks

Creates an orchestrator that coordinates migration operations between the provided registry and version manager. Both dependencies are required for proper migration functionality.

Properties

registry

private readonly registry: MigrationRegistry

Defined in: electron/services/monitoring/MigrationSystem.ts:142


versionManager

private readonly versionManager: VersionManager

Defined in: electron/services/monitoring/MigrationSystem.ts:144

Methods

migrateMonitorData()

migrateMonitorData(monitorType: string, data: {[key: string]: unknown; [key: number]: unknown; [key: symbol]: unknown; history?: StatusHistory[]; activeOperations?: string[]; baselineUrl?: string; bodyKeyword?: string; certificateWarningDays?: number; checkInterval?: number; edgeLocations?: string; expectedHeaderValue?: string; expectedJsonValue?: string; expectedStatusCode?: number; expectedValue?: string; headerName?: string; heartbeatExpectedStatus?: string; heartbeatMaxDriftSeconds?: number; heartbeatStatusField?: string; heartbeatTimestampField?: string; host?: string; id?: string; jsonPath?: string; lastChecked?: Date; maxPongDelayMs?: number; maxReplicationLagSeconds?: number; maxResponseTime?: number; monitoring?: boolean; port?: number; primaryStatusUrl?: string; recordType?: string; replicaStatusUrl?: string; replicationTimestampField?: string; responseTime?: number; retryAttempts?: number; status?: "degraded" | "down" | "paused" | "pending" | "up"; timeout?: number; url?: string; }, fromVersion: string, toVersion: string): Promise<{ appliedMigrations: string[]; data?: {[key: string]: unknown; [key: number]: unknown; [key: symbol]: unknown; history?: StatusHistory[]; activeOperations?: string[]; baselineUrl?: string; bodyKeyword?: string; certificateWarningDays?: number; checkInterval?: number; edgeLocations?: string; expectedHeaderValue?: string; expectedJsonValue?: string; expectedStatusCode?: number; expectedValue?: string; headerName?: string; heartbeatExpectedStatus?: string; heartbeatMaxDriftSeconds?: number; heartbeatStatusField?: string; heartbeatTimestampField?: string; host?: string; id?: string; jsonPath?: string; lastChecked?: Date; maxPongDelayMs?: number; maxReplicationLagSeconds?: number; maxResponseTime?: number; monitoring?: boolean; port?: number; primaryStatusUrl?: string; recordType?: string; replicaStatusUrl?: string; replicationTimestampField?: string; responseTime?: number; retryAttempts?: number; status?: "degraded" | "down" | "paused" | "pending" | "up"; timeout?: number; url?: string; }; errors: string[]; success: boolean; warnings: string[]; }>

Defined in: electron/services/monitoring/MigrationSystem.ts:198

Migrates monitor configuration data from one version to another.

Parameters

monitorType

string

The monitor type identifier (e.g., "http", "ping", "dns")

data

Partial monitor configuration data to migrate

history?

StatusHistory[]

Optional history collection supplied by advanced flows.

activeOperations?

string[]

Array of currently active operations for this monitor

baselineUrl?

string

Baseline origin URL when comparing CDN edge consistency

bodyKeyword?

string

Keyword that must be present in HTTP response bodies

certificateWarningDays?

number

Certificate expiry warning threshold in days for SSL monitoring

checkInterval?

number

Interval between checks in milliseconds

edgeLocations?

string

Optional list of encoded CDN edge endpoints (comma or newline separated)

expectedHeaderValue?

string

Expected value for HTTP header verification

expectedJsonValue?

string

Expected value within a JSON payload

expectedStatusCode?

number

Expected HTTP status code for status-based HTTP monitors

expectedValue?

string

Expected value for DNS record verification

headerName?

string

HTTP header name to inspect

heartbeatExpectedStatus?

string

Expected status string returned by heartbeat endpoints

heartbeatMaxDriftSeconds?

number

Maximum tolerated heartbeat staleness in seconds

heartbeatStatusField?

string

Field name (dot notation supported) that exposes heartbeat status

heartbeatTimestampField?

string

Field name (dot notation supported) that exposes heartbeat timestamp

host?

string

Hostname or IP address to monitor

id?

string

Unique identifier for the monitor

jsonPath?

string

JSON path expression used for HTTP JSON monitors

lastChecked?

Date

Timestamp of the last check performed

maxPongDelayMs?

number

Maximum acceptable delay before a WebSocket pong response (milliseconds)

maxReplicationLagSeconds?

number

Maximum allowable replication lag in seconds

maxResponseTime?

number

Maximum allowed response time for latency monitors

monitoring?

boolean

Whether monitoring is currently active for this monitor

port?

number

Port number for port-based monitoring

primaryStatusUrl?

string

Primary node status endpoint used for replication comparisons

recordType?

string

DNS record type to query (A, AAAA, CNAME, etc.)

replicaStatusUrl?

string

Replica node status endpoint used for replication comparisons

replicationTimestampField?

string

JSON field (dot notation supported) containing replication timestamps

responseTime?

number

Latest response time measurement in milliseconds

retryAttempts?

number

Number of retry attempts when a check fails

status?

"degraded" | "down" | "paused" | "pending" | "up"

Current status of the monitor

timeout?

number

Timeout for monitor checks in milliseconds

url?

string

URL to monitor for HTTP-based checks

fromVersion

string

The current semantic version of the data (e.g., "1.0.0")

toVersion

string

The target semantic version to migrate to (e.g., "1.1.0")

Returns

Promise<{ appliedMigrations: string[]; data?: {[key: string]: unknown; [key: number]: unknown; [key: symbol]: unknown; history?: StatusHistory[]; activeOperations?: string[]; baselineUrl?: string; bodyKeyword?: string; certificateWarningDays?: number; checkInterval?: number; edgeLocations?: string; expectedHeaderValue?: string; expectedJsonValue?: string; expectedStatusCode?: number; expectedValue?: string; headerName?: string; heartbeatExpectedStatus?: string; heartbeatMaxDriftSeconds?: number; heartbeatStatusField?: string; heartbeatTimestampField?: string; host?: string; id?: string; jsonPath?: string; lastChecked?: Date; maxPongDelayMs?: number; maxReplicationLagSeconds?: number; maxResponseTime?: number; monitoring?: boolean; port?: number; primaryStatusUrl?: string; recordType?: string; replicaStatusUrl?: string; replicationTimestampField?: string; responseTime?: number; retryAttempts?: number; status?: "degraded" | "down" | "paused" | "pending" | "up"; timeout?: number; url?: string; }; errors: string[]; success: boolean; warnings: string[]; }>

A Promise resolving to an object containing:

  • appliedMigrations: Array of migration identifiers that were applied
  • data: The transformed configuration data (undefined if errors occurred)
  • errors: Array of error messages encountered during migration
  • success: Boolean indicating if all migrations completed successfully
  • warnings: Array of warning messages (e.g., breaking migration notices)

Remarks

Orchestrates the complete migration process by finding the migration path using MigrationRegistry.getMigrationPath, applying each MigrationRule.transform sequentially, and updating version state on success. Uses withErrorHandling for consistent error handling and structured logging throughout the process.

The method accumulates errors and warnings during execution, stopping on the first transformation failure. Version state is only updated if all migrations complete successfully and at least one migration was applied.

Example

const result = await orchestrator.migrateMonitorData(
"http",
{ url: "example.com" },
"1.0.0",
"1.1.0"
);
if (result.success) {
logger.info(`Applied ${result.appliedMigrations.length} migrations`);
}

Throws

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error When migration orchestration fails due to unexpected errors not related to individual transformation failures

See