Compare commits
3 Commits
8a03f4e171
...
6c72961d12
Author | SHA1 | Date | |
---|---|---|---|
6c72961d12 | |||
1af88c3607 | |||
dbf1283edc |
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@navy.gif/wrappers",
|
"name": "@navy.gif/wrappers",
|
||||||
"version": "1.6.7",
|
"version": "1.6.8",
|
||||||
"description": "Various wrapper classes I use in my projects",
|
"description": "Various wrapper classes I use in my projects",
|
||||||
"repository": "https://git.corgi.wtf/Navy.gif/wrappers.git",
|
"repository": "https://git.corgi.wtf/Navy.gif/wrappers.git",
|
||||||
"author": "Navy.gif",
|
"author": "Navy.gif",
|
||||||
|
@ -24,7 +24,8 @@ export type MariaOptions = {
|
|||||||
cluster?: PoolClusterConfig,
|
cluster?: PoolClusterConfig,
|
||||||
client?: PoolConfig,
|
client?: PoolConfig,
|
||||||
credentials: Credentials,
|
credentials: Credentials,
|
||||||
loggerOptions?: LoggerClientOptions
|
loggerOptions?: LoggerClientOptions,
|
||||||
|
donorQuery?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
type MariaError = {
|
type MariaError = {
|
||||||
@ -93,6 +94,7 @@ class MariaDB
|
|||||||
#cluster: boolean;
|
#cluster: boolean;
|
||||||
#pool: PoolCluster | null;
|
#pool: PoolCluster | null;
|
||||||
#nodes: Node[];
|
#nodes: Node[];
|
||||||
|
#canQueryDonor: boolean;
|
||||||
|
|
||||||
constructor (server: IServer, options: MariaOptions)
|
constructor (server: IServer, options: MariaOptions)
|
||||||
{
|
{
|
||||||
@ -124,6 +126,7 @@ class MariaDB
|
|||||||
this.#afterLastQuery = null;
|
this.#afterLastQuery = null;
|
||||||
|
|
||||||
this.#cluster = this.#credentials.length > 1;
|
this.#cluster = this.#credentials.length > 1;
|
||||||
|
this.#canQueryDonor = options.donorQuery ?? false;
|
||||||
this.#logger = server.createLogger(this, options.loggerOptions);
|
this.#logger = server.createLogger(this, options.loggerOptions);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -338,7 +341,7 @@ class MariaDB
|
|||||||
const pool = this.#pool;
|
const pool = this.#pool;
|
||||||
if (nodeName)
|
if (nodeName)
|
||||||
{
|
{
|
||||||
const available = this.#nodes.filter(n => n.status === 'synced');
|
const available = this.#nodes.filter(n => n.status === 'synced' || !n.status || (this.#canQueryDonor && n.status === 'donor'));
|
||||||
if (!available.length)
|
if (!available.length)
|
||||||
throw new Error('No nodes available for query');
|
throw new Error('No nodes available for query');
|
||||||
const node = this.#nodes.find(n => n.name === nodeName);
|
const node = this.#nodes.find(n => n.name === nodeName);
|
||||||
@ -350,7 +353,7 @@ class MariaDB
|
|||||||
this.#logger.warn(str);
|
this.#logger.warn(str);
|
||||||
nodeName = '*';
|
nodeName = '*';
|
||||||
}
|
}
|
||||||
else if (node.status && node.status !== 'synced')
|
else if (node.status && node.status !== 'synced' && !(this.#canQueryDonor && node.status === 'donor'))
|
||||||
{
|
{
|
||||||
const str = `Node ${nodeName} is currently not synced with the pool and thus unqueryable`;
|
const str = `Node ${nodeName} is currently not synced with the pool and thus unqueryable`;
|
||||||
if (throwError)
|
if (throwError)
|
||||||
|
Loading…
Reference in New Issue
Block a user