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

Why is Metadata still being used instead of Attributes in clientconn.go? #7585

Closed
marsevilspirit opened this issue Sep 3, 2024 · 3 comments
Assignees
Labels
Area: Client Includes Channel/Subchannel/Streams, Connectivity States, RPC Retries, Dial/Call Options and more. Type: Question

Comments

@marsevilspirit
Copy link

Description

While reading the grpc-go source code, I noticed that the Metadata field in clientconn.go has been marked as deprecated with a recommendation to use Attributes instead. However, in the current implementation, particularly at line 923, Metadata is still being used for comparison.

/home/mars/git_clone/grpc-go/clientconn.go|923 col 3-13 note| a.Metadata is deprecated: use Attributes instead.
/home/mars/git_clone/grpc-go/clientconn.go|923 col 17-27 note| b.Metadata is deprecated: use Attributes instead.
/home/mars/git_clone/grpc-go/clientconn.go|1312 col 6-27 note| ac.scopts.CredsBundle is deprecated: Use the Attributes field in resolver.Address to pass arbitrary data to the credential handshaker.
/home/mars/git_clone/grpc-go/clientconn.go|1313 col 24-45 note| ac.scopts.CredsBundle is deprecated: Use the Attributes field in resolver.Address to pass arbitrary data to the credential handshaker.


func equalAddressIgnoringBalAttributes(a, b *resolver.Address) bool {
	return a.Addr == b.Addr && a.ServerName == b.ServerName &&
		a.Attributes.Equal(b.Attributes) &&
		a.Metadata == b.Metadata
}

Questions

  • Since Metadata is marked as deprecated, are there plans to replace it with Attributes in future versions?
  • Is there a specific reason for retaining Metadata in the code, such as backward compatibility or specific use cases?

Additional Information

  • gRPC-Go version: v1.66.0
  • Go version: go1.23.0 linux/amd64
  • Operating System: arch linux 1.10.7-arch1-1
  • Editor: neovim

Thank you for your help and for the great work on this project! I’m looking forward to understanding the reasoning behind this decision.

@purnesh42H purnesh42H self-assigned this Sep 7, 2024
@purnesh42H purnesh42H added the Area: Client Includes Channel/Subchannel/Streams, Connectivity States, RPC Retries, Dial/Call Options and more. label Sep 7, 2024
@marsevilspirit
Copy link
Author

Can Attributes fully replace Metadata? If so, can the Metadata field be removed from the Address struct?

@purnesh42H
Copy link
Contributor

purnesh42H commented Sep 17, 2024

@marsevilspirit yes, the recommended way to store and compare arbitrary data associated with an address is to use the Attributes field, which is of type attributes.Attributes. This field can store key-value pairs, and the attributes package provides methods for comparing them.

Regarding, retaining metadata, I will confirm with team if its safe to remove or not at this point. Does that answer your question? If not, please let me know if any other question by reopening the issue

@purnesh42H
Copy link
Contributor

We have a pending item to remove resolver.address.metadata as part of #6472. @marsevilspirit fyi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Client Includes Channel/Subchannel/Streams, Connectivity States, RPC Retries, Dial/Call Options and more. Type: Question
Projects
None yet
Development

No branches or pull requests

2 participants