File tree Expand file tree Collapse file tree 3 files changed +7
-5
lines changed Expand file tree Collapse file tree 3 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -81,7 +81,8 @@ addDefaults(config, {
81
81
password : "" ,
82
82
port : 5432 ,
83
83
max : 10 ,
84
- idleTimeoutMillis : 10000
84
+ idleTimeoutMillis : 10000 ,
85
+ maxTries : 3
85
86
} ,
86
87
postgresReadOnly : {
87
88
enabled : false ,
@@ -92,7 +93,8 @@ addDefaults(config, {
92
93
port : 5432 ,
93
94
readTimeout : 250 ,
94
95
max : 10 ,
95
- idleTimeoutMillis : 10000
96
+ idleTimeoutMillis : 10000 ,
97
+ maxTries : 3
96
98
} ,
97
99
dumpDatabase : {
98
100
enabled : false ,
Original file line number Diff line number Diff line change @@ -33,8 +33,6 @@ export class Postgres implements IDatabase {
33
33
private poolRead : Pool ;
34
34
private lastPoolReadFail = 0 ;
35
35
36
- private maxTries = 3 ;
37
-
38
36
constructor ( private config : DatabaseConfig ) { }
39
37
40
38
async init ( ) : Promise < void > {
@@ -141,7 +139,8 @@ export class Postgres implements IDatabase {
141
139
142
140
Logger . error ( `prepare (postgres) try ${ tries } : ${ err } ` ) ;
143
141
}
144
- } while ( this . isReadQuery ( type ) && tries < this . maxTries ) ;
142
+ } while ( this . isReadQuery ( type ) && tries < ( lastPool === this . pool
143
+ ? this . config . postgres . maxTries : this . config . postgresReadOnly . maxTries ) ) ;
145
144
}
146
145
147
146
private getPool ( type : string , options : QueryOption ) : Pool {
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ interface RedisConfig extends redis.RedisClientOptions {
8
8
9
9
export interface CustomPostgresConfig extends PoolConfig {
10
10
enabled : boolean ;
11
+ maxTries : number ;
11
12
}
12
13
13
14
export interface CustomPostgresReadOnlyConfig extends CustomPostgresConfig {
You can’t perform that action at this time.
0 commit comments