All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.dist.src.config.middleware.experimental-middleware-factory.js Maven / Gradle / Ivy

The newest version!
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MiddlewareFactory = void 0;
const experimental_event_loop_perf_middleware_1 = require("./experimental-event-loop-perf-middleware");
const experimental_metrics_logging_middleware_1 = require("./experimental-metrics-logging-middleware");
const experimental_active_request_count_middleware_1 = require("./experimental-active-request-count-middleware");
const experimental_metrics_csv_middleware_1 = require("./experimental-metrics-csv-middleware");
const experimental_garbage_collection_middleware_1 = require("./experimental-garbage-collection-middleware");
// Static class encapsulating the factory functionality
class MiddlewareFactory {
    static createMetricsMiddlewares(loggerFactory, options) {
        const middlewares = [];
        if (options.eventLoopMetricsLog === true) {
            middlewares.push(new experimental_event_loop_perf_middleware_1.ExperimentalEventLoopPerformanceMetricsMiddleware(loggerFactory));
        }
        if (options.perRequestMetricsCSVPath !== undefined) {
            middlewares.push(new experimental_metrics_csv_middleware_1.ExperimentalMetricsCsvMiddleware(options.perRequestMetricsCSVPath, loggerFactory));
        }
        else if (options.perRequestMetricsLog === true) {
            middlewares.push(new experimental_metrics_logging_middleware_1.ExperimentalMetricsLoggingMiddleware(loggerFactory));
        }
        if (options.activeRequestCountMetricsLog === true) {
            middlewares.push(new experimental_active_request_count_middleware_1.ExperimentalActiveRequestCountLoggingMiddleware(loggerFactory));
        }
        if (options.garbageCollectionMetricsLog === true) {
            middlewares.push(new experimental_garbage_collection_middleware_1.ExperimentalGarbageCollectionPerformanceMetricsMiddleware(loggerFactory));
        }
        return middlewares;
    }
}
exports.MiddlewareFactory = MiddlewareFactory;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXhwZXJpbWVudGFsLW1pZGRsZXdhcmUtZmFjdG9yeS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9jb25maWcvbWlkZGxld2FyZS9leHBl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yeVxuICAgICAgICApXG4gICAgICApO1xuICAgIH1cblxuICAgIHJldHVybiBtaWRkbGV3YXJlcztcbiAgfVxufVxuIl19




© 2015 - 2024 Weber Informatics LLC | Privacy Policy