[NET-9468, NET-9902] Differentiate the ListExportedServicesQuery dependency based on the provided partition #1949
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prior to this change, the template below would result in printing the services exported by the
default
partition twice.This is because the
String
func -- used to uniquely identify a dependency provider -- returned the same value each time and wasn't differentiated based on its arguments. Consul-template would then consider these the same dependency and return the same set of services each time.The fix is to include the differentiator -- the partition name in this case -- in the unique identity returned by
.String()
for the dependency. With this change, consul-template correctly identifies the code above as having two different dependencies and thus will create a separate dependency for each partition and make the appropriate calls to Consul.Note
For use with Consul CE, the provided partition name should be an empty string. This change will still work in that case as
<Dependency>.String()
will returnlist.exportedServices()
.