Skip to content

Commit 888e2a3

Browse files
authored
chore: Cleanup IConfigurationStore interface (#84)
* chore: Cleanup IConfigurationStore interface * fix tests
1 parent 138c404 commit 888e2a3

File tree

3 files changed

+9
-22
lines changed

3 files changed

+9
-22
lines changed

src/configuration-store/configuration-store.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@
2121
* implementation specific and handled upstream.
2222
*/
2323
export interface IConfigurationStore<T> {
24-
servingStore: ISyncStore<T>;
25-
persistentStore: IAsyncStore<T> | null;
26-
2724
init(): Promise<void>;
2825
get(key: string): T | null;
2926
getKeys(): string[];

src/configuration-store/hybrid.store.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@ import { logger, loggerPrefix } from '../application-logger';
33
import { IAsyncStore, IConfigurationStore, ISyncStore } from './configuration-store';
44

55
export class HybridConfigurationStore<T> implements IConfigurationStore<T> {
6-
servingStore: ISyncStore<T>;
7-
persistentStore: IAsyncStore<T> | null;
8-
9-
constructor(servingStore: ISyncStore<T>, persistentStore: IAsyncStore<T> | null) {
10-
this.servingStore = servingStore;
11-
this.persistentStore = persistentStore;
12-
}
6+
constructor(
7+
private readonly servingStore: ISyncStore<T>,
8+
private readonly persistentStore: IAsyncStore<T> | null,
9+
) {}
1310

1411
/**
1512
* Initialize the configuration store by loading the entries from the persistent store into the serving store.
@@ -41,8 +38,8 @@ export class HybridConfigurationStore<T> implements IConfigurationStore<T> {
4138
}
4239

4340
public async isExpired(): Promise<boolean> {
44-
const isExpired = (await this.persistentStore?.isExpired()) ?? true;
45-
return isExpired;
41+
const isExpired = await this.persistentStore?.isExpired();
42+
return isExpired ?? true;
4643
}
4744

4845
public get(key: string): T | null {

src/configuration-store/memory.store.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IAsyncStore, IConfigurationStore, ISyncStore } from './configuration-store';
1+
import { IConfigurationStore, ISyncStore } from './configuration-store';
22

33
export class MemoryStore<T> implements ISyncStore<T> {
44
private store: Record<string, T> = {};
@@ -23,15 +23,8 @@ export class MemoryStore<T> implements ISyncStore<T> {
2323
}
2424

2525
export class MemoryOnlyConfigurationStore<T> implements IConfigurationStore<T> {
26-
servingStore: ISyncStore<T>;
27-
persistentStore: IAsyncStore<T> | null;
28-
private initialized: boolean;
29-
30-
constructor() {
31-
this.servingStore = new MemoryStore<T>();
32-
this.persistentStore = null;
33-
this.initialized = false;
34-
}
26+
private readonly servingStore: ISyncStore<T> = new MemoryStore<T>();
27+
private initialized = false;
3528

3629
init(): Promise<void> {
3730
this.initialized = true;

0 commit comments

Comments
 (0)