File tree Expand file tree Collapse file tree 2 files changed +20
-17
lines changed Expand file tree Collapse file tree 2 files changed +20
-17
lines changed Original file line number Diff line number Diff line change @@ -62,13 +62,18 @@ export class RegionProfileManager {
6262
6363 private readonly cache = new ( class extends CachedResource < RegionProfile [ ] > {
6464 constructor ( private readonly profileProvider : ( ) => Promise < RegionProfile [ ] > ) {
65- super ( 'aws.amazonq.regionProfiles.cache' , 60000 , {
66- resource : {
67- locked : false ,
68- timestamp : 0 ,
69- result : undefined ,
65+ super (
66+ 'aws.amazonq.regionProfiles.cache' ,
67+ 60000 ,
68+ {
69+ resource : {
70+ locked : false ,
71+ timestamp : 0 ,
72+ result : undefined ,
73+ } ,
7074 } ,
71- } )
75+ { timeout : 15000 , interval : 1500 , truthy : true }
76+ )
7277 }
7378
7479 override resourceProvider ( ) : Promise < RegionProfile [ ] > {
Original file line number Diff line number Diff line change @@ -30,7 +30,8 @@ export abstract class CachedResource<V> {
3030 constructor (
3131 private readonly key : globalKey ,
3232 private readonly expirationInMilli : number ,
33- private readonly defaultValue : GlobalStateSchema < V >
33+ private readonly defaultValue : GlobalStateSchema < V > ,
34+ private readonly waitUntilOption : { timeout : number ; interval : number ; truthy : boolean }
3435 ) { }
3536
3637 abstract resourceProvider ( ) : Promise < V >
@@ -88,16 +89,13 @@ export abstract class CachedResource<V> {
8889 return undefined
8990 }
9091
91- const lock = await waitUntil (
92- async ( ) => {
93- const lock = await _acquireLock ( )
94- logger . info ( `try obtain resource cache read lock %s` , lock )
95- if ( lock ) {
96- return lock
97- }
98- } ,
99- { timeout : 15000 , interval : 1500 , truthy : true } // TODO: pass via ctor
100- )
92+ const lock = await waitUntil ( async ( ) => {
93+ const lock = await _acquireLock ( )
94+ logger . info ( `try obtain resource cache read lock %s` , lock )
95+ if ( lock ) {
96+ return lock
97+ }
98+ } , this . waitUntilOption )
10199
102100 return lock
103101 }
You can’t perform that action at this time.
0 commit comments