@bsv/overlay-express
Version:
BSV Blockchain Overlay Express
59 lines • 1.81 kB
TypeScript
import { Db } from 'mongodb';
/**
* Configuration for the Janitor Service
*/
export interface JanitorConfig {
mongoDb: Db;
logger?: typeof console;
requestTimeoutMs?: number;
hostDownRevokeScore?: number;
}
/**
* JanitorService runs a single pass of health checks on SHIP and SLAP outputs.
* It validates domain names and checks /health endpoints to ensure services are operational.
*
* When a service is down, it increments a "down" counter. When healthy, it decrements.
* If the down counter reaches HOST_DOWN_REVOKE_SCORE, it deletes the output from the database.
*
* This service is designed to be run periodically via external schedulers (e.g., cron, docker-compose).
*/
export declare class JanitorService {
private readonly mongoDb;
private readonly logger;
private readonly requestTimeoutMs;
private readonly hostDownRevokeScore;
constructor(config: JanitorConfig);
/**
* Runs a single pass of health checks on all SHIP and SLAP outputs
*/
run(): Promise<void>;
/**
* Checks all outputs for a specific topic
*/
private checkTopicOutputs;
/**
* Checks a single output for health
*/
private checkOutput;
/**
* Extracts URL from output record
*/
private extractURLFromOutput;
/**
* Validates if a string is a valid domain name
*/
private isValidDomain;
/**
* Checks the /health endpoint of a service
*/
private checkHealthEndpoint;
/**
* Handles a healthy output by decrementing its down counter
*/
private handleHealthyOutput;
/**
* Handles an unhealthy output by incrementing its down counter and deleting if threshold is reached
*/
private handleUnhealthyOutput;
}
//# sourceMappingURL=JanitorService.d.ts.map