refactor: minor refactor

This commit is contained in:
Fabio Di Stasio 2022-03-12 10:01:22 +01:00
parent 4be55f3fe9
commit f0d368e3e3
5 changed files with 5 additions and 42 deletions

View File

@ -40,7 +40,7 @@ export default connections => {
} }
try { try {
const connection = await ClientsFactory.getConnection({ const connection = await ClientsFactory.getClient({
client: conn.client, client: conn.client,
params params
}); });
@ -100,7 +100,7 @@ export default connections => {
} }
try { try {
const connection = ClientsFactory.getConnection({ const connection = ClientsFactory.getClient({
client: conn.client, client: conn.client,
params, params,
poolSize: 5 poolSize: 5

View File

@ -22,7 +22,7 @@ export class ClientsFactory {
* @returns Database Connection * @returns Database Connection
* @memberof ClientsFactory * @memberof ClientsFactory
*/ */
static getConnection (args) { static getClient (args) {
switch (args.client) { switch (args.client) {
case 'mysql': case 'mysql':
case 'maria': case 'maria':

View File

@ -1,35 +0,0 @@
import { MysqlExporter } from './sql/MysqlExporter';
export class ExporterFactory {
/**
* Returns a data exporter class instance.
*
* @param {Object} args
* @param {String} args.client
* @param {Object} args.params
* @param {String} args.params.host
* @param {Number} args.params.port
* @param {String} args.params.password
* @param {String=} args.params.database
* @param {String=} args.params.schema
* @param {String} args.params.ssh.host
* @param {String} args.params.ssh.username
* @param {String} args.params.ssh.password
* @param {Number} args.params.ssh.port
* @param {Number=} args.poolSize
* @returns Exporter Instance
* @memberof ExporterFactory
*/
static get (args) {
switch (type) {
case 'mysql':
exporter = new MysqlExporter(connections[uid], rest);
break;
default:
return {
status: 'error',
response: `${type} exporter not aviable`
};
}
}
}

View File

@ -5,14 +5,13 @@ let exporter;
process.on('message', async ({ type, client, tables, options }) => { process.on('message', async ({ type, client, tables, options }) => {
if (type === 'init') { if (type === 'init') {
const connection = await ClientsFactory.getConnection({ const connection = await ClientsFactory.getClient({
client: client.name, client: client.name,
params: client.config, params: client.config,
poolSize: 5 poolSize: 5
}); });
await connection.connect(); await connection.connect();
// TODO: exporter factory class
switch (client.name) { switch (client.name) {
case 'mysql': case 'mysql':
case 'maria': case 'maria':

View File

@ -4,7 +4,7 @@ let importer;
process.on('message', async ({ type, dbConfig, options }) => { process.on('message', async ({ type, dbConfig, options }) => {
if (type === 'init') { if (type === 'init') {
const connection = await ClientsFactory.getConnection({ const connection = await ClientsFactory.getClient({
client: options.type, client: options.type,
params: { params: {
...dbConfig, ...dbConfig,
@ -15,7 +15,6 @@ process.on('message', async ({ type, dbConfig, options }) => {
const pool = await connection.getConnectionPool(); const pool = await connection.getConnectionPool();
// TODO: importer factory class
switch (options.type) { switch (options.type) {
case 'mysql': case 'mysql':
case 'maria': case 'maria':