pandora-metrics
Version: 
## Overview
44 lines • 1.68 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const EndPointService_1 = require("./service/EndPointService");
const ActuatorRestService_1 = require("./service/ActuatorRestService");
class MetricsActuatorManager {
    constructor(options) {
        this.actuatorConfig = {
            endPoint: {}
        };
        this.logger = options.logger;
        this.actuatorConfig = options.config;
        // 初始化各个 endpoints
        this.initEndPoints();
        // 初始化 http 服务
        this.initRestService();
    }
    initEndPoints() {
        this.endPointService = new EndPointService_1.EndPointService();
        this.endPointService.setLogger(this.logger);
        let instances = [];
        const endPoints = this.actuatorConfig['endPoint'];
        for (let endPointName in endPoints) {
            if (endPoints[endPointName].enabled !== false) {
                let ins = new endPoints[endPointName].target();
                if (endPoints[endPointName].initConfig) {
                    ins.setConfig(endPoints[endPointName].initConfig);
                }
                instances.push(ins);
            }
        }
        this.endPointService.setEndPointIns(instances);
        this.endPointService.start();
    }
    initRestService() {
        this.actuatorRestService = new ActuatorRestService_1.ActuatorRestService(this.endPointService);
        this.actuatorRestService.start(this.actuatorConfig);
    }
    destory() {
        this.actuatorRestService.stop();
        this.endPointService.stop();
    }
}
exports.MetricsActuatorManager = MetricsActuatorManager;
//# sourceMappingURL=MetricsActuatorManager.js.map