Skip to content

Conversation

@nexcode
Copy link

@nexcode nexcode commented Nov 5, 2025

In gRPC you can create manual Resolver for manual name resolution management. This resolver has an UpdateState method, which receives a State object. This object has an Attributes field, which is used to pass various parameters to load balancers.

The PickerBuilder interface contains a build method that receives a PickerBuildInfo object containing connection information, but lacking the Attributes that are passed when updating the resolver state.

PickerBuildInfo now contains a new Attributes field:

// PickerBuildInfo contains information needed by the picker builder to
// construct a picker.
type PickerBuildInfo struct {
	// ReadySCs is a map from all ready SubConns to the Addresses used to
	// create them.
	ReadySCs map[balancer.SubConn]SubConnInfo

	// Attributes contains arbitrary data about the resolver intended for
	// consumption by the load balancing policy. This is a pointer to resolver.State Attributes.
	Attributes *attributes.Attributes
}

Now when implementing the PickerBuilder interface you can get these Attributes (and based on their values, configure the load balancer's operating logic):

type pickerBuilder struct{}

func (*pickerBuilder) Build(pickerInfo base.PickerBuildInfo) balancer.Picker {
	myKey := pickerInfo.Attributes.Value("myKey")
	...
}

This change does not change any external APIs and is fully backwards compatible.

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Nov 5, 2025

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: nexcode / name: Oleg Trifonov (c3e965c)

@codecov
Copy link

codecov bot commented Nov 5, 2025

Codecov Report

❌ Patch coverage is 90.00000% with 1 line in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (master@7472d57). Learn more about missing BASE report.
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
balancer/base/balancer.go 90.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master    #8696   +/-   ##
=========================================
  Coverage          ?   83.24%           
=========================================
  Files             ?      416           
  Lines             ?    32304           
  Branches          ?        0           
=========================================
  Hits              ?    26892           
  Misses            ?     4027           
  Partials          ?     1385           
Files with missing lines Coverage Δ
balancer/base/base.go 0.00% <ø> (ø)
balancer/base/balancer.go 51.37% <90.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Pranjali-2501
Copy link
Contributor

Hi @nexcode,

Thank you for raising this PR and for your contribution!

We generally prefer to discuss new features or standard API changes in a GitHub issue—or via the gRFC for larger, cross-language proposals—before they are implemented in a PR. This helps us discuss the design, necessity, and potential advantages of proposed changes first.

Could you please raise an issue/gRFC detailing the need for this change and the use cases it enables?

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants