Skip to content

Commit ca37ce0

Browse files
committed
Make method naming consistent in ConfigServiceBase
1 parent 47078f3 commit ca37ce0

8 files changed

+29
-29
lines changed

src/AutoPollConfigService.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export class AutoPollConfigService extends ConfigServiceBase<AutoPollOptions> im
7474
return this.getCacheState(this.options.cache.getInMemory());
7575
}
7676

77-
async getConfig(): Promise<ProjectConfig> {
77+
async getConfigAsync(): Promise<ProjectConfig> {
7878
this.options.logger.debug("AutoPollConfigService.getConfig() called.");
7979

8080
function logSuccess(logger: LoggerWrapper) {

src/ConfigCatClient.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ export class ConfigCatClient implements IConfigCatClient {
616616
this.options.logger.debug("getSettingsAsync() called.");
617617

618618
const getRemoteConfigAsync: () => Promise<SettingsWithRemoteConfig> = async () => {
619-
const config = await this.configService!.getConfig();
619+
const config = await this.configService!.getConfigAsync();
620620
const settings = !config.isEmpty ? config.config!.settings : null;
621621
return [settings, config];
622622
};

src/ConfigServiceBase.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export const enum ClientCacheState {
4848
export interface IConfigService {
4949
readonly readyPromise: Promise<ClientCacheState>;
5050

51-
getConfig(): Promise<ProjectConfig>;
51+
getConfigAsync(): Promise<ProjectConfig>;
5252

5353
refreshConfigAsync(): Promise<[RefreshResult, ProjectConfig]>;
5454

@@ -103,7 +103,7 @@ export abstract class ConfigServiceBase<TOptions extends OptionsBase> {
103103
return this.status === ConfigServiceStatus.Disposed;
104104
}
105105

106-
abstract getConfig(): Promise<ProjectConfig>;
106+
abstract getConfigAsync(): Promise<ProjectConfig>;
107107

108108
async refreshConfigAsync(): Promise<[RefreshResult, ProjectConfig]> {
109109
const latestConfig = await this.syncUpWithCache();

src/LazyLoadConfigService.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class LazyLoadConfigService extends ConfigServiceBase<LazyLoadOptions> im
2020
this.readyPromise = this.getReadyPromise(initialCacheSyncUp);
2121
}
2222

23-
async getConfig(): Promise<ProjectConfig> {
23+
async getConfigAsync(): Promise<ProjectConfig> {
2424
this.options.logger.debug("LazyLoadConfigService.getConfig() called.");
2525

2626
function logExpired(logger: LoggerWrapper, appendix = "") {

src/ManualPollConfigService.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class ManualPollConfigService extends ConfigServiceBase<ManualPollOptions
2424
return ClientCacheState.HasCachedFlagDataOnly;
2525
}
2626

27-
async getConfig(): Promise<ProjectConfig> {
27+
async getConfigAsync(): Promise<ProjectConfig> {
2828
this.options.logger.debug("ManualPollService.getConfig() called.");
2929
return await this.syncUpWithCache();
3030
}

test/ConfigCatClientTests.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -1235,7 +1235,7 @@ describe("ConfigCatClient", () => {
12351235

12361236
// 1. Checks that client is initialized to offline mode
12371237
assert.isTrue(client.isOffline);
1238-
assert.isTrue((await configService.getConfig()).isEmpty);
1238+
assert.isTrue((await configService.getConfigAsync()).isEmpty);
12391239

12401240
// 2. Checks that repeated calls to setOffline() have no effect
12411241
client.setOffline();
@@ -1254,7 +1254,7 @@ describe("ConfigCatClient", () => {
12541254
assert.isFalse(client.isOffline);
12551255
assert.equal(expectedFetchTimes, configFetcher.calledTimes);
12561256

1257-
const etag1 = ((await configService.getConfig()).httpETag ?? "0") as any | 0;
1257+
const etag1 = ((await configService.getConfigAsync()).httpETag ?? "0") as any | 0;
12581258
if (configService instanceof LazyLoadConfigService) {
12591259
expectedFetchTimes++;
12601260
}
@@ -1268,7 +1268,7 @@ describe("ConfigCatClient", () => {
12681268
assert.isFalse(client.isOffline);
12691269
assert.equal(expectedFetchTimes, configFetcher.calledTimes);
12701270

1271-
const etag2 = ((await configService.getConfig()).httpETag ?? "0") as any | 0;
1271+
const etag2 = ((await configService.getConfigAsync()).httpETag ?? "0") as any | 0;
12721272
assert.isTrue(etag2 > etag1);
12731273

12741274
assert.isTrue(refreshResult.isSuccess);
@@ -1311,7 +1311,7 @@ describe("ConfigCatClient", () => {
13111311

13121312
assert.equal(expectedFetchTimes, configFetcher.calledTimes);
13131313

1314-
const etag1 = ((await configService.getConfig()).httpETag ?? "0") as any | 0;
1314+
const etag1 = ((await configService.getConfigAsync()).httpETag ?? "0") as any | 0;
13151315
if (configService instanceof LazyLoadConfigService) {
13161316
expectedFetchTimes++;
13171317
}
@@ -1330,15 +1330,15 @@ describe("ConfigCatClient", () => {
13301330
assert.isTrue(client.isOffline);
13311331
assert.equal(expectedFetchTimes, configFetcher.calledTimes);
13321332

1333-
assert.equal(etag1, ((await configService.getConfig()).httpETag ?? "0") as any | 0);
1333+
assert.equal(etag1, ((await configService.getConfigAsync()).httpETag ?? "0") as any | 0);
13341334

13351335
// 4. Checks that forceRefreshAsync() does not initiate a HTTP call in offline mode
13361336
const refreshResult = await client.forceRefreshAsync();
13371337

13381338
assert.isTrue(client.isOffline);
13391339
assert.equal(expectedFetchTimes, configFetcher.calledTimes);
13401340

1341-
assert.equal(etag1, ((await configService.getConfig()).httpETag ?? "0") as any | 0);
1341+
assert.equal(etag1, ((await configService.getConfigAsync()).httpETag ?? "0") as any | 0);
13421342

13431343
assert.isFalse(refreshResult.isSuccess);
13441344
expect(refreshResult.errorMessage).to.contain("offline mode");
@@ -1403,7 +1403,7 @@ describe("ConfigCatClient", () => {
14031403
const originalConfigService = client["configService"] as ConfigServiceBase<OptionsBase>;
14041404
client["configService"] = new class implements IConfigService {
14051405
readonly readyPromise = Promise.resolve(ClientCacheState.NoFlagData);
1406-
getConfig(): Promise<ProjectConfig> { return Promise.resolve(ProjectConfig.empty); }
1406+
getConfigAsync(): Promise<ProjectConfig> { return Promise.resolve(ProjectConfig.empty); }
14071407
refreshConfigAsync(): Promise<[RefreshResult, ProjectConfig]> { return Promise.reject(expectedErrorException); }
14081408
get isOffline(): boolean { return false; }
14091409
setOnline(): void { }
@@ -1488,7 +1488,7 @@ describe("ConfigCatClient", () => {
14881488

14891489
client["configService"] = new class implements IConfigService {
14901490
readonly readyPromise = Promise.resolve(ClientCacheState.NoFlagData);
1491-
getConfig(): Promise<ProjectConfig> { return Promise.resolve(ProjectConfig.empty); }
1491+
getConfigAsync(): Promise<ProjectConfig> { return Promise.resolve(ProjectConfig.empty); }
14921492
refreshConfigAsync(): Promise<[RefreshResult, ProjectConfig]> { throw errorException; }
14931493
get isOffline(): boolean { return false; }
14941494
setOnline(): void { }

test/ConfigServiceBaseTests.ts

+14-14
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ describe("ConfigServiceBaseTests", () => {
205205
fetcherMock.object(),
206206
options);
207207

208-
const actualProjectConfig = await service.getConfig();
208+
const actualProjectConfig = await service.getConfigAsync();
209209

210210
// Assert
211211

@@ -253,7 +253,7 @@ describe("ConfigServiceBaseTests", () => {
253253
fetcherMock.object(),
254254
options);
255255

256-
const actualProjectConfig = await service.getConfig();
256+
const actualProjectConfig = await service.getConfigAsync();
257257

258258
// Assert
259259

@@ -300,7 +300,7 @@ describe("ConfigServiceBaseTests", () => {
300300
fetcherMock.object(),
301301
options);
302302

303-
const actualProjectConfig = await service.getConfig();
303+
const actualProjectConfig = await service.getConfigAsync();
304304

305305
// Assert
306306

@@ -411,7 +411,7 @@ describe("ConfigServiceBaseTests", () => {
411411
assert.isEmpty(clientReadyEvents);
412412
assert.isEmpty(configChangedEvents);
413413

414-
await service.getConfig();
414+
await service.getConfigAsync();
415415

416416
await delay(100); // allow a little time for the client to raise ConfigChanged
417417

@@ -485,7 +485,7 @@ describe("ConfigServiceBaseTests", () => {
485485

486486
// Act
487487

488-
const actualConfig = await service.getConfig();
488+
const actualConfig = await service.getConfigAsync();
489489

490490
// Assert
491491

@@ -520,7 +520,7 @@ describe("ConfigServiceBaseTests", () => {
520520

521521
// Act
522522

523-
const actualConfig = await service.getConfig();
523+
const actualConfig = await service.getConfigAsync();
524524

525525
// Assert
526526

@@ -612,7 +612,7 @@ describe("ConfigServiceBaseTests", () => {
612612
cacheMock.verify(v => v.set(It.IsAny<string>(), It.IsAny<ProjectConfig>()), Times.Once());
613613
});
614614

615-
it("AutoPollConfigService - getConfig() should return cached config when cached config is not expired", async () => {
615+
it("AutoPollConfigService - getConfigAsync() should return cached config when cached config is not expired", async () => {
616616
// Arrange
617617

618618
const pollIntervalSeconds = 2;
@@ -645,7 +645,7 @@ describe("ConfigServiceBaseTests", () => {
645645
// Give a bit of time to the polling loop to do the first iteration.
646646
await delay(pollIntervalSeconds / 4 * 1000);
647647

648-
const actualPc = await service.getConfig();
648+
const actualPc = await service.getConfigAsync();
649649

650650
// Assert
651651

@@ -656,7 +656,7 @@ describe("ConfigServiceBaseTests", () => {
656656
service.dispose();
657657
});
658658

659-
it("AutoPollConfigService - getConfig() should wait for fetch when cached config is expired", async () => {
659+
it("AutoPollConfigService - getConfigAsync() should wait for fetch when cached config is expired", async () => {
660660
// Arrange
661661

662662
const pollIntervalSeconds = 2;
@@ -689,7 +689,7 @@ describe("ConfigServiceBaseTests", () => {
689689
// Give a bit of time to the polling loop to do the first iteration.
690690
await delay(pollIntervalSeconds / 4 * 1000);
691691

692-
const actualPc = await service.getConfig();
692+
const actualPc = await service.getConfigAsync();
693693

694694
// Assert
695695

@@ -702,7 +702,7 @@ describe("ConfigServiceBaseTests", () => {
702702
service.dispose();
703703
});
704704

705-
it("LazyLoadConfigService - getConfig() should return cached config when cached config is not expired", async () => {
705+
it("LazyLoadConfigService - getConfigAsync() should return cached config when cached config is not expired", async () => {
706706
// Arrange
707707

708708
const cacheTimeToLiveSeconds = 5;
@@ -731,7 +731,7 @@ describe("ConfigServiceBaseTests", () => {
731731

732732
const service = new LazyLoadConfigService(fetcherMock.object(), options);
733733

734-
const actualPc = await service.getConfig();
734+
const actualPc = await service.getConfigAsync();
735735

736736
// Assert
737737

@@ -740,7 +740,7 @@ describe("ConfigServiceBaseTests", () => {
740740
fetcherMock.verify(v => v.fetchLogic(It.IsAny<OptionsBase>(), It.IsAny<string>()), Times.Never());
741741
});
742742

743-
it("LazyLoadConfigService - getConfig() should fetch when cached config is expired", async () => {
743+
it("LazyLoadConfigService - getConfigAsync() should fetch when cached config is expired", async () => {
744744
// Arrange
745745

746746
const cacheTimeToLiveSeconds = 5;
@@ -772,7 +772,7 @@ describe("ConfigServiceBaseTests", () => {
772772

773773
const service = new LazyLoadConfigService(fetcherMock.object(), options);
774774

775-
const actualPc = await service.getConfig();
775+
const actualPc = await service.getConfigAsync();
776776

777777
// Assert
778778

test/DataGovernanceTests.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ export class FakeConfigServiceBase extends ConfigServiceBase<FakeOptions> {
290290

291291
get readyPromise(): Promise<ClientCacheState> { throw new Error("Getter not implemented."); }
292292

293-
getConfig(): Promise<ProjectConfig> { return Promise.resolve(ProjectConfig.empty); }
293+
getConfigAsync(): Promise<ProjectConfig> { return Promise.resolve(ProjectConfig.empty); }
294294

295295
refreshLogicAsync(): Promise<[FetchResult, ProjectConfig]> {
296296
return this.refreshConfigCoreAsync(ProjectConfig.empty, false);

0 commit comments

Comments
 (0)