mirror of https://github.com/Fabio286/antares.git
refactor: minor refactor
This commit is contained in:
parent
4be55f3fe9
commit
f0d368e3e3
|
@ -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
|
||||
|
|
|
@ -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':
|
||||
|
|
|
@ -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`
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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':
|
||||
|
|
|
@ -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':
|
||||
|
|
Loading…
Reference in New Issue