How to use the @terascope/job-components.Assignment.Worker 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-test-harness / src / job-harness.ts View on Github external
function throwInvalidContext(method: string, context: WorkerExecutionContext|SlicerExecutionContext): never {
    const { assignment } = context.context;
    const expected = assignment === Assignment.Worker ? Assignment.ExecutionController : Assignment.Worker;
    const error = new Error(`${method} can only be run with assignment of "${expected}"`);
    Error.captureStackTrace(error, throwInvalidContext);
    throw error;
}
github terascope / teraslice / packages / teraslice-test-harness / src / job-harness.ts View on Github external
constructor(job: JobConfig, options: JobHarnessOptions) {
        const context = new TestContext(`job-harness:${job.name}`);
        context.assignment = options.assignment || Assignment.Worker;

        const jobSchema = makeJobSchema(context);
        const executionConfig = validateJobConfig(jobSchema, job) as ExecutionConfig;
        this.context = makeExecutionContext({
            context,
            executionConfig
        });
    }