Skip to main content

Development

When developing on an operation you'll need to be aware of three packages.

Reader

A reader is expected to have the following folder structure:

<example-reader>
├── fetcher.js
├── schema.js
└── slicer.js

Fetcher

'use strict';

const { Fetcher } = require('@terascope/job-components');

class ExampleFetcher extends Fetcher {
constructor(...args) {
super(...args);
this._initialized = false;
this._shutdown = false;
}

async initialize() {
this._initialized = true;
return super.initialize();
}

async shutdown() {
this._shutdown = true;
return super.shutdown();
}

async fetch() {
const result = [];
for (let i = 0; i < 10; i++) {
result.push({
id: i,
data: [Math.random(), Math.random(), Math.random()],
});
}
return result;
}
}

module.exports = ExampleFetcher;
import { Fetcher } from '@terascope/job-components';

export default class ExampleFetcher extends Fetcher {
_initialized = false;
_shutdown = false;

async initialize() {
this._initialized = true;
return super.initialize();
}

async shutdown() {
this._shutdown = true;
return super.shutdown();
}

async fetch() {
const result = [];
for (let i = 0; i < 10; i++) {
result.push({
id: i,
data: [Math.random(), Math.random(), Math.random()],
});
}
return result;
}
}

Schema

'use strict';

const { Fetcher } = require('@terascope/job-components');

class ExampleFetcher extends Fetcher {
constructor(...args) {
super(...args);
this._initialized = false;
this._shutdown = false;
}

async initialize() {
this._initialized = true;
return super.initialize();
}

async shutdown() {
this._shutdown = true;
return super.shutdown();
}

async fetch() {
const result = [];
for (let i = 0; i < 10; i++) {
result.push({
id: i,
data: [Math.random(), Math.random(), Math.random()],
});
}
return result;
}
}

module.exports = ExampleFetcher;
import { Fetcher } from '@terascope/job-components';

export default class ExampleFetcher extends Fetcher {
_initialized = false;
_shutdown = false;

async initialize() {
this._initialized = true;
return super.initialize();
}

async shutdown() {
this._shutdown = true;
return super.shutdown();
}

async fetch() {
const result = [];
for (let i = 0; i < 10; i++) {
result.push({
id: i,
data: [Math.random(), Math.random(), Math.random()],
});
}
return result;
}
}