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.
Description (what this PR does / why we need it):
In the original code, the management of the "heartbeat" coroutine in the Registry relies on the "option.ctx" passed in from the outside. In the default case, this may lead to the "heartbeat" goroutine being unable to correctly determine whether it should end based on the state of the context during its execution.
In reality, in addition to using a timeout context for managing the Register and DeRegister methods, the Registry also needs a separate context to control its lifecycle.
This context should obviously be controlled by the Registry itself: initialized during Register and canceled during DeRegister.
This is the origin and purpose of this PR.
在原本的代码中, Registry的heartbeat协程的管理由外部传入的option.ctx管理, 在默认的情况下, 这有可能导致heartbeat goroutine在运行过程中无法正确的通过context 的状态来判断是否应该结束.
实际上, 除了在管理 Register 以及 DeRegister 两个方法超时的context 外, Registry还需要一个控制生命周期的ctx.
这个ctx显然应该由Registry自己来进行控制: 即在Register时进行初始化, 在Degister时进行cancel.
这就是这个PR的来源以及作用.
Which issue(s) this PR fixes (resolves / be part of):
Other special notes for the reviewers: