How to use the @terascope/job-components.processorShim function in @terascope/job-components

To help you get started, we’ve selected a few @terascope/job-components examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github terascope / teraslice / packages / teraslice-op-test-harness / lib / operation.js View on Github external
async init() {
        const {
            context,
            logger,
            retryData = [],
            operationFn: op,
            opConfig,
            executionConfig: exConfig
        } = this;
        const oldStyle = (op.newReader !== undefined || op.newProcessor !== undefined);

        if (!this._hasInit) {
            if (oldStyle) {
                if (this.isProcessor) {
                    const { Processor } = processorShim(op);
                    this.operation = new Processor(context, opConfig, exConfig);
                } else {
                    const { Fetcher, Slicer } = readerShim(op);
                    if (this.isReader) this.operation = new Fetcher(context, opConfig, exConfig);
                    if (this.isSlicer) this.operation = new Slicer(context, opConfig, exConfig);
                }
                if (logger) this.operation.logger = logger;
                await this.operation.initialize(retryData);
            } else {
                let newOp;
                if (op.Processor) newOp = new op.Processor(context, opConfig, exConfig);
                if (op.Fetcher) newOp = new op.Fetcher(context, opConfig, exConfig);
                if (op.Slicer) newOp = new op.Slicer(context, opConfig, exConfig);

                this.operation = newOp;
                if (logger) this.operation.logger = logger;