Skip to content

Load balance support#42

Merged
linglingye001 merged 4 commits intorelease/v1.2.0from
linglingye/LB
Aug 8, 2025
Merged

Load balance support#42
linglingye001 merged 4 commits intorelease/v1.2.0from
linglingye/LB

Conversation

@linglingye001
Copy link
Member

No description provided.

@RichardChen820 RichardChen820 requested a review from Copilot August 6, 2025 07:48
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements load balancing support for the Azure App Configuration client, allowing for distributed load across multiple replicas when multiple endpoints are available.

  • Adds a new LoadBalancingEnabled option to control load balancing behavior
  • Implements client rotation logic to distribute requests across available replicas
  • Adds tracing support to track when load balancing is enabled

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
azureappconfiguration/options.go Adds LoadBalancingEnabled configuration option
azureappconfiguration/internal/tracing/tracing.go Adds load balancing tracing support and tags
azureappconfiguration/azureappconfiguration.go Implements core load balancing logic with client rotation
azureappconfiguration/failover_test.go Comprehensive test coverage for load balancing functionality

}
}

// rotateSliceInPlace rotates a slice left by k positions using the reverse-reverse algorithm.
Copy link

Copilot AI Aug 6, 2025

Choose a reason for hiding this comment

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

The rotateSliceInPlace function lacks documentation explaining its purpose, parameters, and the reverse-reverse algorithm it implements. Consider adding a docstring that explains the algorithm and its time/space complexity.

Suggested change
// rotateSliceInPlace rotates a slice left by k positions using the reverse-reverse algorithm.
// rotateSliceInPlace rotates a slice left by k positions in place using the reverse-reverse algorithm.
//
// Parameters:
// slice: The slice to be rotated. The rotation is performed in place.
// k: The number of positions to rotate the slice to the left. If k >= len(slice), k is reduced modulo len(slice).
//
// Algorithm:
// The function uses the reverse-reverse algorithm:
// 1. Reverse the entire slice.
// 2. Reverse the first len(slice)-k elements.
// 3. Reverse the remaining k elements.
// This results in the slice being rotated left by k positions.
//
// Time Complexity: O(n), where n is the length of the slice.
// Space Complexity: O(1), as the rotation is performed in place.

Copilot uses AI. Check for mistakes.
@@ -849,6 +864,56 @@ func (azappcfg *AzureAppConfiguration) updateFeatureFlagTracing(featureFlag map[
}
}

Copy link

Copilot AI Aug 6, 2025

Choose a reason for hiding this comment

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

The rotateClientsToNextEndpoint function lacks documentation. It should include a docstring explaining its purpose, parameters, and how it modifies the clients slice in-place for load balancing.

Suggested change
// rotateClientsToNextEndpoint rotates the clients slice in-place so that the client following
// the last successful endpoint becomes the first element. This is used for load balancing
// across multiple endpoints. If the last successful endpoint is found, the slice is rotated
// to start with the next client. If there is only one client or the endpoint is not found,
// the slice is not modified.
//
// Parameters:
// - clients: A slice of pointers to configurationClientWrapper. This slice is modified in-place.
// - lastSuccessfulEndpoint: The endpoint string of the last successful client.

Copilot uses AI. Check for mistakes.
@RichardChen820
Copy link
Member

LGTM

Base automatically changed from linglingye/failover to release/v1.2.0 August 8, 2025 05:30
@linglingye001 linglingye001 merged commit d6c5297 into release/v1.2.0 Aug 8, 2025
13 checks passed
@linglingye001 linglingye001 deleted the linglingye/LB branch August 8, 2025 05:47
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