UNPKG

@bitblit/epsilon

Version:

Tiny adapter to simplify building API gateway Lambda APIS

76 lines 3.33 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.SingleThreadLocalBackgroundManager = void 0; const rxjs_1 = require("rxjs"); const common_1 = require("@bitblit/ratchet/common"); const abstract_background_manager_1 = require("./abstract-background-manager"); /** * Handles all submission of work to the background processing system. * * Note that this does NOT validate the input, it just passes it along. This is * because it creates a circular reference to the processors if we try since they * define the type and validation. */ class SingleThreadLocalBackgroundManager extends abstract_background_manager_1.AbstractBackgroundManager { get backgroundManagerName() { return 'SingleThreadLocalBackgroundManager'; } constructor() { super(); this._localBus = new rxjs_1.Subject(); } immediateProcessQueue() { return this._localBus; } addEntryToQueue(entry, fireStartMessage) { return __awaiter(this, void 0, void 0, function* () { const wrapped = yield this.wrapEntryForInternal(entry); const rval = wrapped.guid; common_1.Logger.info('Add entry to queue (local) : %j : Start : %s', entry, fireStartMessage); this._localBus.next(wrapped); return rval; }); } fireImmediateProcessRequest(entry) { return __awaiter(this, void 0, void 0, function* () { let rval = null; const wrapped = yield this.wrapEntryForInternal(entry); rval = wrapped.guid; common_1.Logger.info('Fire immediately (local) : %j ', entry); this._localBus.next(wrapped); return rval; }); } fireStartProcessingRequest() { return __awaiter(this, void 0, void 0, function* () { let rval = null; common_1.Logger.info('Fire start processing request (local, ignored)'); rval = 'NO-OP'; return rval; }); } fetchApproximateNumberOfQueueEntries() { return __awaiter(this, void 0, void 0, function* () { let rval = null; rval = 0; // No queue when running locally return rval; }); } takeEntryFromBackgroundQueue() { return __awaiter(this, void 0, void 0, function* () { common_1.Logger.info('Called takeEntryFromBackgroundQueue on SingleThreadedLocal - returning empty'); return []; }); } } exports.SingleThreadLocalBackgroundManager = SingleThreadLocalBackgroundManager; //# sourceMappingURL=single-thread-local-background-manager.js.map