mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-11-10 09:07:47 +01:00
Make max tries configurable
This commit is contained in:
parent
47a6a13bdb
commit
6be2f96f26
3 changed files with 7 additions and 5 deletions
|
@ -81,7 +81,8 @@ addDefaults(config, {
|
|||
password: "",
|
||||
port: 5432,
|
||||
max: 10,
|
||||
idleTimeoutMillis: 10000
|
||||
idleTimeoutMillis: 10000,
|
||||
maxTries: 3
|
||||
},
|
||||
postgresReadOnly: {
|
||||
enabled: false,
|
||||
|
@ -92,7 +93,8 @@ addDefaults(config, {
|
|||
port: 5432,
|
||||
readTimeout: 250,
|
||||
max: 10,
|
||||
idleTimeoutMillis: 10000
|
||||
idleTimeoutMillis: 10000,
|
||||
maxTries: 3
|
||||
},
|
||||
dumpDatabase: {
|
||||
enabled: false,
|
||||
|
|
|
@ -33,8 +33,6 @@ export class Postgres implements IDatabase {
|
|||
private poolRead: Pool;
|
||||
private lastPoolReadFail = 0;
|
||||
|
||||
private maxTries = 3;
|
||||
|
||||
constructor(private config: DatabaseConfig) {}
|
||||
|
||||
async init(): Promise<void> {
|
||||
|
@ -141,7 +139,8 @@ export class Postgres implements IDatabase {
|
|||
|
||||
Logger.error(`prepare (postgres) try ${tries}: ${err}`);
|
||||
}
|
||||
} while (this.isReadQuery(type) && tries < this.maxTries);
|
||||
} while (this.isReadQuery(type) && tries < (lastPool === this.pool
|
||||
? this.config.postgres.maxTries : this.config.postgresReadOnly.maxTries));
|
||||
}
|
||||
|
||||
private getPool(type: string, options: QueryOption): Pool {
|
||||
|
|
|
@ -8,6 +8,7 @@ interface RedisConfig extends redis.RedisClientOptions {
|
|||
|
||||
export interface CustomPostgresConfig extends PoolConfig {
|
||||
enabled: boolean;
|
||||
maxTries: number;
|
||||
}
|
||||
|
||||
export interface CustomPostgresReadOnlyConfig extends CustomPostgresConfig {
|
||||
|
|
Loading…
Reference in a new issue