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):
问题:服务在收到
os.Signal
后退出,但并未返回服务在关闭过程中出现的错误。原因:在
errgroup
中返回了ctx.Err()
。按照原有的代码逻辑,如果不考虑极端情况,在收到os.Signal
后errgroup
都会返回context.Canceled
,因为errgroup
只会返回第一个错误,而context.Canceled
这个错误在Run
方法中会被忽略,这就导致了Run
未捕获到服务关闭过程中的错误。p.s. 这里把
for
代码也删了,因为考虑到ctx.Err()
仅会返回context.Canceled
以及context.DeadlineExceeded
,结合上下文,该ctx
不会出现超时的情况,所以不需要返回ctx.Err()
。Which issue(s) this PR fixes (resolves / be part of):
Other special notes for the reviewers: