From f0d368e3e31e2130ffcd18a953cbebdcda5187e5 Mon Sep 17 00:00:00 2001 From: Fabio Di Stasio Date: Sat, 12 Mar 2022 10:01:22 +0100 Subject: [PATCH] refactor: minor refactor --- src/main/ipc-handlers/connection.js | 4 +-- src/main/libs/ClientsFactory.js | 2 +- src/main/libs/exporters/ExporterFactory.js | 35 ---------------------- src/main/workers/exporter.js | 3 +- src/main/workers/importer.js | 3 +- 5 files changed, 5 insertions(+), 42 deletions(-) delete mode 100644 src/main/libs/exporters/ExporterFactory.js diff --git a/src/main/ipc-handlers/connection.js b/src/main/ipc-handlers/connection.js index c539f75a..696aeb99 100644 --- a/src/main/ipc-handlers/connection.js +++ b/src/main/ipc-handlers/connection.js @@ -40,7 +40,7 @@ export default connections => { } try { - const connection = await ClientsFactory.getConnection({ + const connection = await ClientsFactory.getClient({ client: conn.client, params }); @@ -100,7 +100,7 @@ export default connections => { } try { - const connection = ClientsFactory.getConnection({ + const connection = ClientsFactory.getClient({ client: conn.client, params, poolSize: 5 diff --git a/src/main/libs/ClientsFactory.js b/src/main/libs/ClientsFactory.js index 5a38f90f..0ab6d5ba 100644 --- a/src/main/libs/ClientsFactory.js +++ b/src/main/libs/ClientsFactory.js @@ -22,7 +22,7 @@ export class ClientsFactory { * @returns Database Connection * @memberof ClientsFactory */ - static getConnection (args) { + static getClient (args) { switch (args.client) { case 'mysql': case 'maria': diff --git a/src/main/libs/exporters/ExporterFactory.js b/src/main/libs/exporters/ExporterFactory.js deleted file mode 100644 index 7c3165dc..00000000 --- a/src/main/libs/exporters/ExporterFactory.js +++ /dev/null @@ -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` - }; - } - } -} diff --git a/src/main/workers/exporter.js b/src/main/workers/exporter.js index 3033967c..43a0aff0 100644 --- a/src/main/workers/exporter.js +++ b/src/main/workers/exporter.js @@ -5,14 +5,13 @@ let exporter; process.on('message', async ({ type, client, tables, options }) => { if (type === 'init') { - const connection = await ClientsFactory.getConnection({ + const connection = await ClientsFactory.getClient({ client: client.name, params: client.config, poolSize: 5 }); await connection.connect(); - // TODO: exporter factory class switch (client.name) { case 'mysql': case 'maria': diff --git a/src/main/workers/importer.js b/src/main/workers/importer.js index 8b10f853..672c8a11 100644 --- a/src/main/workers/importer.js +++ b/src/main/workers/importer.js @@ -4,7 +4,7 @@ let importer; process.on('message', async ({ type, dbConfig, options }) => { if (type === 'init') { - const connection = await ClientsFactory.getConnection({ + const connection = await ClientsFactory.getClient({ client: options.type, params: { ...dbConfig, @@ -15,7 +15,6 @@ process.on('message', async ({ type, dbConfig, options }) => { const pool = await connection.getConnectionPool(); - // TODO: importer factory class switch (options.type) { case 'mysql': case 'maria':