UNPKG

@livy/util

Version:
32 lines (31 loc) 1.08 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MirrorSyncHandlerMixin = void 0; const mixin_1 = require("../mixin"); const is_sync_handler_interface_1 = require("./is-sync-handler-interface"); /** * Mixin which implements the `SyncHandlerInterface` by making the * `handle`/`handleBatchSync` method mirroring the `handle`/`handleBatch` method */ exports.MirrorSyncHandlerMixin = (0, mixin_1.Mixin)(BaseClass => { return class MirrorSyncHandlerMixin extends BaseClass { constructor(...args) { super(...args); if (!(0, is_sync_handler_interface_1.isSyncHandlerInterface)(this)) { throw new Error('Cannot use MirrorSyncHandlerMixin on an async handler'); } } /** * @inheritdoc */ handle(record) { return Promise.resolve(this.handleSync(record)); } /** * @inheritdoc */ handleBatch(records) { return Promise.resolve(this.handleBatchSync(records)); } }; });