UNPKG

couch-elastic-stream

Version:

data streaming from couchdb to elastic via kafka.

36 lines (29 loc) 942 B
const { SinkConnector } = require("kafka-connect"); const { Client } = require('@elastic/elasticsearch'); const Promise = require('bluebird'); class ElasticSinkConnector extends SinkConnector { start(properties, callback) { this.properties = properties; this.client = new Client({node : properties.clientNode}); this.client.ping({}, { requestTimeout : properties.requestTimeout }, (err, res) => { if(!err && res.statusCode === 200) { callback(null); } callback(err); }); } taskConfigs(maxTasks, callback) { const taskConfig = { maxTasks, client: this.client, index: this.properties.index, type: this.properties.type }; callback(null, taskConfig); } stop() { } } module.exports = ElasticSinkConnector;