Update sync server to use refactored API

master
Sven Slootweg 2 years ago
parent 6e172dd04d
commit dbd15aa1d7

@ -31,8 +31,7 @@ const { testValue } = require("@validatem/core");
const matchesFormat = require("@validatem/matches-format");
const isString = require("@validatem/is-string");
const initialize = require("../src/initialize");
const errors = require("../src/errors");
const createKernel = require("../src/kernel");
let argv = yargs.argv;
let configurationPath = argv._[0];
@ -43,20 +42,8 @@ let absoluteConfigurationPath = path.join(process.cwd(), configurationPath);
let configuration = require(absoluteConfigurationPath);
return Promise.try(() => {
// FIXME: Deduplicate this with kernel! Also other common wiring across binaries...
return initialize({
knexfile: {
client: "pg",
connection: configuration.database,
pool: { min: 0, max: 32 },
migrations: { tableName: "srap_knex_migrations" }
}
});
}).then((state) => {
let { db, knex } = state;
const queries = require("../src/queries")(state);
return createKernel(configuration);
}).then((kernel) => {
let app = express();
let router = expressPromiseRouter();
@ -125,7 +112,7 @@ return Promise.try(() => {
: undefined;
return pipe([
queries.getUpdates(knex, { prefix: req.query.prefix, timestamp: timestamp }),
kernel.getUpdates({ prefix: req.query.prefix, timestamp }),
map((item) => JSON.stringify(item) + "\n"),
fromNodeStream(res)
]).read();

@ -126,6 +126,9 @@ module.exports = async function createKernel(_configuration) {
metrics: metrics
};
});
},
getUpdates: function ({ prefix, timestamp }) {
return backend.topLevel.getUpdateStream(null, { prefix, timestamp });
}
};
};

Loading…
Cancel
Save