-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
49 lines (36 loc) · 1.34 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"use strict";
const PubSubSourceConfig = require("./lib/PubSubSourceConfig.js");
const PubSubSinkConfig = require("./lib/PubSubSinkConfig.js");
const PubSubSourceConnector = require("./lib/source/PubSubSourceConnector.js");
const PubSubSinkConnector = require("./lib/sink/PubSubSinkConnector.js");
const PubSubSourceTask = require("./lib/source/PubSubSourceTask.js");
const PubSubSinkTask = require("./lib/sink/PubSubSinkTask.js");
const JsonConverter = require("./lib/utils/JsonConverter.js");
const ConverterFactory = require("./lib/utils/ConverterFactory.js");
const runSourceConnector = (properties, converters = [], onError = null) => {
const config = new PubSubSourceConfig(properties,
PubSubSourceConnector,
PubSubSourceTask, [JsonConverter].concat(converters));
if (onError) {
config.on("error", onError);
}
return config.run().then(() => {
return config;
});
};
const runSinkConnector = (properties, converters = [], onError = null) => {
const config = new PubSubSinkConfig(properties,
PubSubSinkConnector,
PubSubSinkTask, [JsonConverter].concat(converters));
if (onError) {
config.on("error", onError);
}
return config.run().then(() => {
return config;
});
};
module.exports = {
runSourceConnector,
runSinkConnector,
ConverterFactory
};