Open
Conversation
修复 nacos-group#210:subscribe 以及 selectOneHealthyInstance 传递 clusters 参数后未生效的问题。 原因:Service::get_instance_list 方法接收了 cluster_names 参数但未使用, 直接调用 get_all_instances 返回所有实例,导致 clusters 过滤完全失效。 修复:当 cluster_names 非空时,按 cluster_name 过滤实例列表;为空时保持原有行为。
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
修复问题
修复 #210:subscribe 以及 selectOneHealthyInstance 传递 clusters 参数后未生效的问题。
原因分析
Service::get_instance_list方法接收了cluster_names参数(变量名为_cluster_names,带下划线前缀),但方法体内直接调用get_all_instances返回所有实例,完全忽略了 clusters 过滤条件。修复方案
当
cluster_names非空时,在遍历实例时增加cluster_names.contains(&x.cluster_name)过滤条件,只返回属于指定 cluster 的实例;当cluster_names为空时保持原有行为,返回所有实例。