config-loader: review fixes in RemoteConfigSource and StaticConfigSource
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -62,9 +62,9 @@ export interface RemoteConfigSourceOptions {
|
||||
url: string;
|
||||
|
||||
/**
|
||||
* The interval in seconds to reload the config from the remote URL.
|
||||
* How often to reload the config from the remote URL, defaults to 1 minute.
|
||||
*
|
||||
* Set to Infinity to disable reloading.
|
||||
* Set to Infinity to disable reloading, for example `{ days: Infinity }`.
|
||||
*/
|
||||
reloadInterval?: HumanDuration;
|
||||
|
||||
|
||||
@@ -60,11 +60,17 @@ class StaticObservableConfigSource implements ConfigSource {
|
||||
},
|
||||
});
|
||||
|
||||
options?.signal?.addEventListener('abort', () => {
|
||||
sub.unsubscribe();
|
||||
queue.length = 0;
|
||||
deferred.resolve();
|
||||
});
|
||||
const signal = options?.signal;
|
||||
if (signal) {
|
||||
const onAbort = () => {
|
||||
sub.unsubscribe();
|
||||
queue.length = 0;
|
||||
deferred.resolve();
|
||||
signal.removeEventListener('abort', onAbort);
|
||||
};
|
||||
|
||||
signal.addEventListener('abort', onAbort);
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
await deferred.promise;
|
||||
@@ -109,11 +115,8 @@ export class StaticConfigSource implements ConfigSource {
|
||||
};
|
||||
}
|
||||
|
||||
if (isObservable(data)) {
|
||||
return new StaticObservableConfigSource(
|
||||
data as Observable<JsonObject>,
|
||||
context,
|
||||
);
|
||||
if (isObservable<JsonObject>(data)) {
|
||||
return new StaticObservableConfigSource(data, context);
|
||||
}
|
||||
|
||||
if (isAsyncIterable(data)) {
|
||||
|
||||
Reference in New Issue
Block a user