Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getProcessor(_opConfig, extraContext) {
let opConfig = _opConfig;
if (_opConfig == null) {
opConfig = {};
}
if (!opConfig._op) {
opConfig._op = 'test-op-name';
}
const operation = this.operationFn;
const { schema, context } = this;
// run the jobConfig and opConfig through the validator to get
// complete and convict validated configs
const jobConfig = validateJobConfig(schema, { operations: [{ _op: 'noop' }, opConfig] });
return operation.newProcessor(
_.assign({}, context, extraContext),
validateOpConfig(operation.schema(), opConfig),
jobConfig
);
}
opConfig = schema.validate(newOpConfig || exConfig.operations[0]);
if (isProcessor) {
exConfig.operations = [{ _op: 'test-reader' }, opConfig];
} else {
exConfig.operations = [opConfig, { _op: 'noop' }];
}
} else {
const opPosition = isProcessor ? 1 : 0;
opConfig = schema.validate(newOpConfig || exConfig.operations[opPosition]);
exConfig.operations[opPosition] = opConfig;
}
this.opConfig = opConfig;
const executionConfig = validateJobConfig(this.schema, exConfig);
schema.validateJob(executionConfig);
this.executionConfig = executionConfig;
this.retryData = retryData;
if (clients) {
this.setClients(clients);
}
const instance = new Operation({
op,
context,
opConfig,
logger,
retryData,
executionConfig,
type
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
});
}