Skip to content

Commit

Permalink
fix: 옵션명 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
humy2833 committed Apr 15, 2024
1 parent 25724a1 commit 21ad465
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/cormo/lib/adapters/mysql.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface AdapterSettingsMySQL {
collation?: string;
pool_size?: number;
query_timeout?: number;
idle_timeout?: number;
max_lifetime?: number;
replication?: {
use_master_for_read?: boolean;
read_replicas: Array<{
Expand Down
10 changes: 5 additions & 5 deletions packages/cormo/lib/adapters/mysql.js
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ class MySQLAdapter extends sql_base_1.SQLAdapterBase {
this._client._node_id = 'MASTER';
this._client.queryAsync = util_1.default.promisify(this._client.query);
this._client.getConnectionAsync = util_1.default.promisify(this._client.getConnection);
this._setEvent(this._client, settings.idle_timeout);
this._setEvent(this._client, settings.max_lifetime);
if (settings.replication) {
this._read_clients = [];
if (settings.replication.use_master_for_read) {
Expand All @@ -817,7 +817,7 @@ class MySQLAdapter extends sql_base_1.SQLAdapterBase {
read_client._node_id = `SLAVE${i + 1}`;
read_client.queryAsync = util_1.default.promisify(read_client.query);
read_client.getConnectionAsync = util_1.default.promisify(read_client.getConnection);
this._setEvent(read_client, settings.idle_timeout);
this._setEvent(read_client, settings.max_lifetime);
this._read_clients.push(read_client);
}
}
Expand Down Expand Up @@ -1281,15 +1281,15 @@ class MySQLAdapter extends sql_base_1.SQLAdapterBase {
return MySQLAdapter.wrapError(msg, cause);
}
/** @internal */
_setEvent(client, idle_timeout) {
if (!idle_timeout || idle_timeout < 0) {
_setEvent(client, max_lifetime) {
if (!max_lifetime || max_lifetime < 0) {
return;
}
client.on('connection', (connection) => {
connection._connected_ts = Date.now();
});
client.on('release', (connection) => {
if (Date.now() - connection._connected_ts >= idle_timeout) {
if (Date.now() - connection._connected_ts >= max_lifetime) {
connection.destroy();
}
});
Expand Down
12 changes: 6 additions & 6 deletions packages/cormo/src/adapters/mysql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export interface AdapterSettingsMySQL {
collation?: string;
pool_size?: number;
query_timeout?: number;
idle_timeout?: number;
max_lifetime?: number;
replication?: {
use_master_for_read?: boolean;
read_replicas: Array<{
Expand Down Expand Up @@ -873,7 +873,7 @@ export class MySQLAdapter extends SQLAdapterBase {
this._client._node_id = 'MASTER';
this._client.queryAsync = util.promisify(this._client.query);
this._client.getConnectionAsync = util.promisify(this._client.getConnection);
this._setEvent(this._client, settings.idle_timeout);
this._setEvent(this._client, settings.max_lifetime);

if (settings.replication) {
this._read_clients = [];
Expand All @@ -896,7 +896,7 @@ export class MySQLAdapter extends SQLAdapterBase {
read_client._node_id = `SLAVE${i + 1}`;
read_client.queryAsync = util.promisify(read_client.query);
read_client.getConnectionAsync = util.promisify(read_client.getConnection);
this._setEvent(read_client, settings.idle_timeout);
this._setEvent(read_client, settings.max_lifetime);
this._read_clients.push(read_client);
}
}
Expand Down Expand Up @@ -1379,15 +1379,15 @@ export class MySQLAdapter extends SQLAdapterBase {
}

/** @internal */
private _setEvent(client: any, idle_timeout?: number) {
if (!idle_timeout || idle_timeout < 0) {
private _setEvent(client: any, max_lifetime?: number) {
if (!max_lifetime || max_lifetime < 0) {
return;
}
client.on('connection', (connection: any) => {
connection._connected_ts = Date.now();
});
client.on('release', (connection: any) => {
if (Date.now() - connection._connected_ts >= idle_timeout) {
if (Date.now() - connection._connected_ts >= max_lifetime) {
connection.destroy();
}
});
Expand Down

0 comments on commit 21ad465

Please sign in to comment.