Skip to content

Conversation

@linglingye001
Copy link
Member

@linglingye001 linglingye001 commented Nov 19, 2024

A load balancing mode has been introduced, enabling your application to distribute requests to App Configuration across all available replicas.

Usage:

const appConfig = await load("YOUR-CONNECTION-STRING", {loadBalancingEnabled: true})

client: AppConfigurationClient;
backoffEndTime: number = 0; // Timestamp
#failedAttempts: number = 0;
failedAttempts: number = 0;
Copy link
Member

@zhiyuanliang-ms zhiyuanliang-ms Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you have to expose failedAttempt to be public for testing, you should make this private and create another public property which only has getter. And the getter will return the private #failedAttempt. This can make sure failedAttempt won't be modified outside of the class. And add comment to explain the purpose.

if (this.failedAttempts > 0) {
this.failedAttempts = 0;
}
this.failedAttempts -= 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

failedAttempts can be negative. This doesn't make sense. If this behavior is only for testing, don't do that.

}
});
// one request for key values, one request for feature flags
expect(fakeClientWrapper_1.failedAttempts).eq(-1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check this pattern. You can follow this pattern to verify how many times something is called. You can do whatever you want when you stub the fakeClientWrapper. You can set a local counter and when the client is called, counter += 1

@linglingye001 linglingye001 merged commit 2315e4c into preview Nov 27, 2024
4 checks passed
@linglingye001 linglingye001 deleted the linglingye/loadBalance branch November 27, 2024 06:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants