Aetherance commented on code in PR #3305:
URL: https://github.com/apache/dubbo-go/pull/3305#discussion_r3367136212
##########
cluster/router/router.go:
##########
@@ -95,9 +95,20 @@ type Cache interface {
// GetInvokers returns the snapshot of received invokers.
GetInvokers() []base.Invoker
- // FindAddrPool returns address pool associated with the given Poolable
instance.
- FindAddrPool(Poolable) AddrPool
+ // FindAddrPool returns the address pool, the invoker snapshot, and the
generation of that
+ // snapshot in a single locked read. The generation lets callers verify
the pool/invokers
+ // belong to the same generation the chain snapshotted for the current
route, so the bitmap
+ // indices stay aligned with the invoker slice and the route is not
served from a snapshot
+ // produced by a concurrent SetInvokers.
+ FindAddrPool(Poolable) (AddrPool, []base.Invoker, uint64)
Review Comment:
这确实是个 breaking change,但是 `AddrPool` 里的 bitmap index 依赖同一代 invoker
snapshot,单独返回 `AddrPool` 不能表达安全的使用语义。把 pool、invokers 和 generation 放在同一个
`FindAddrPool` 返回值里,可以保证调用方一次读取到一致快照,也避免后续误用旧 API。
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]