Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load balance support #135

Merged
merged 2 commits into from
Nov 27, 2024
Merged

Load balance support #135

merged 2 commits into from
Nov 27, 2024

Conversation

linglingye001
Copy link
Contributor

@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})

@@ -12,7 +12,7 @@ export class ConfigurationClientWrapper {
endpoint: string;
client: AppConfigurationClient;
backoffEndTime: number = 0; // Timestamp
#failedAttempts: number = 0;
failedAttempts: number = 0;
Copy link
Contributor

@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
Contributor

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
Contributor

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.

2 participants