"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.__tsfTypeAliases = void 0;
exports.registerWorkerObserver = registerWorkerObserver;
exports.notifyWorkerObservers = notifyWorkerObservers;
const tslib_1 = require("tslib");
const _a = tslib_1.__importStar(require("@zyno-io/ts-server-foundation/type-metadata-runtime"));
const workerObservers = new Set();
function registerWorkerObserver(observer) {
    workerObservers.add(observer);
    return () => workerObservers.delete(observer);
}
function notifyWorkerObservers(entry) {
    for (const observer of workerObservers) {
        try {
            observer(entry);
        }
        catch {
            // Observers must never affect worker execution.
        }
    }
}
exports.__tsfTypeAliases = _a.decodeCompactMetadataV1("[1,{\"WorkerObservation\":{\"kind\":12,\"types\":[{\"kind\":18,\"types\":[{\"kind\":20,\"name\":\"type\",\"type\":{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":\"added\"},{\"kind\":10,\"literal\":\"active\"},{\"kind\":10,\"literal\":\"delayed\"}]},\"optional\":false},{\"kind\":20,\"name\":\"job\",\"type\":{\"kind\":18,\"typeName\":\"QueuedWorkerJob\",\"types\":[{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"queue\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"name\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"data\",\"type\":{\"kind\":2,\"typeName\":\"I\"},\"optional\":false},{\"kind\":20,\"name\":\"jobClass\",\"type\":{\"kind\":2,\"typeName\":\"JobClass\",\"typeArguments\":[{\"kind\":2,\"typeName\":\"I\"}]},\"optional\":false},{\"kind\":20,\"name\":\"options\",\"type\":{\"kind\":18,\"typeName\":\"IJobOptions\",\"types\":[{\"kind\":20,\"name\":\"delay\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"queueName\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"runInTest\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"runImmediately\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"recordToDatabase\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"repeatKey\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":4}]},\"optional\":true}]},\"optional\":false},{\"kind\":20,\"name\":\"createdAt\",\"type\":{\"kind\":16,\"typeName\":\"Date\",\"classType\":{\"$tsf\":0}},\"optional\":false},{\"kind\":20,\"name\":\"shouldExecuteAt\",\"type\":{\"kind\":16,\"typeName\":\"Date\",\"classType\":{\"$tsf\":0}},\"optional\":false},{\"kind\":20,\"name\":\"attemptsMade\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"status\",\"type\":{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":\"queued\"},{\"kind\":10,\"literal\":\"completed\"},{\"kind\":10,\"literal\":\"failed\"},{\"kind\":10,\"literal\":\"skipped\"}],\"typeName\":\"WorkerJobStatus\"},\"optional\":false},{\"kind\":20,\"name\":\"result\",\"type\":{\"kind\":12,\"types\":[{\"kind\":2},{\"kind\":4}]},\"optional\":true}]},\"optional\":false}]},{\"kind\":18,\"types\":[{\"kind\":20,\"name\":\"type\",\"type\":{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":\"completed\"},{\"kind\":10,\"literal\":\"failed\"}]},\"optional\":false},{\"kind\":20,\"name\":\"job\",\"type\":{\"kind\":18,\"typeName\":\"QueuedWorkerJob\",\"types\":[{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"queue\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"name\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"data\",\"type\":{\"kind\":2,\"typeName\":\"I\"},\"optional\":false},{\"kind\":20,\"name\":\"jobClass\",\"type\":{\"kind\":2,\"typeName\":\"JobClass\",\"typeArguments\":[{\"kind\":2,\"typeName\":\"I\"}]},\"optional\":false},{\"kind\":20,\"name\":\"options\",\"type\":{\"kind\":18,\"typeName\":\"IJobOptions\",\"types\":[{\"kind\":20,\"name\":\"delay\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"queueName\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"runInTest\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"runImmediately\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"recordToDatabase\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"repeatKey\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":4}]},\"optional\":true}]},\"optional\":false},{\"kind\":20,\"name\":\"createdAt\",\"type\":{\"kind\":16,\"typeName\":\"Date\",\"classType\":{\"$tsf\":0}},\"optional\":false},{\"kind\":20,\"name\":\"shouldExecuteAt\",\"type\":{\"kind\":16,\"typeName\":\"Date\",\"classType\":{\"$tsf\":0}},\"optional\":false},{\"kind\":20,\"name\":\"attemptsMade\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"status\",\"type\":{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":\"queued\"},{\"kind\":10,\"literal\":\"completed\"},{\"kind\":10,\"literal\":\"failed\"},{\"kind\":10,\"literal\":\"skipped\"}],\"typeName\":\"WorkerJobStatus\"},\"optional\":false},{\"kind\":20,\"name\":\"result\",\"type\":{\"kind\":12,\"types\":[{\"kind\":2},{\"kind\":4}]},\"optional\":true}]},\"optional\":false},{\"kind\":20,\"name\":\"record\",\"type\":{\"kind\":18,\"typeName\":\"WorkerJobRecord\",\"types\":[{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"queue\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"queueId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"attempt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"name\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"data\",\"type\":{\"kind\":2,\"typeName\":\"I\"},\"optional\":false},{\"kind\":20,\"name\":\"traceId\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":5}]},\"optional\":false},{\"kind\":20,\"name\":\"status\",\"type\":{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":\"completed\"},{\"kind\":10,\"literal\":\"failed\"}]},\"optional\":false},{\"kind\":20,\"name\":\"result\",\"type\":{\"kind\":2,\"typeName\":\"O\"},\"optional\":false},{\"kind\":20,\"name\":\"createdAt\",\"type\":{\"kind\":16,\"typeName\":\"Date\",\"classType\":{\"$tsf\":0}},\"optional\":false},{\"kind\":20,\"name\":\"shouldExecuteAt\",\"type\":{\"kind\":16,\"typeName\":\"Date\",\"classType\":{\"$tsf\":0}},\"optional\":false},{\"kind\":20,\"name\":\"executedAt\",\"type\":{\"kind\":16,\"typeName\":\"Date\",\"classType\":{\"$tsf\":0}},\"optional\":false},{\"kind\":20,\"name\":\"completedAt\",\"type\":{\"kind\":16,\"typeName\":\"Date\",\"classType\":{\"$tsf\":0}},\"optional\":false}]},\"optional\":false}]}],\"typeName\":\"WorkerObservation\"},\"WorkerObserver\":{\"kind\":2,\"typeName\":\"(entry: WorkerObservation) =\\u003e void\",\"typeName\":\"WorkerObserver\"}}]", [() => (typeof Date !== "undefined" ? Date : (typeof exports !== "undefined" ? exports.Date : undefined))]);
//# sourceMappingURL=observer.js.map