-
Notifications
You must be signed in to change notification settings - Fork 816
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use direct outbound for history client #4619
Use direct outbound for history client #4619
Conversation
3025999
to
9346303
Compare
5367341
to
e630366
Compare
func NewPeerResolver(numberOfShards int, membership membership.Monitor, addressMapper AddressMapperFn) PeerResolver { | ||
return PeerResolver{ | ||
numberOfShards: numberOfShards, | ||
membership: membership, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you need only history
resolver, you can replace membership with resolver
and pass history resolver here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, updated the PR.
client/history/client.go
Outdated
logger log.Logger, | ||
) Client { | ||
return &clientImpl{ | ||
numberOfShards: numberOfShards, | ||
rpcMaxSizeInBytes: rpcMaxSizeInBytes, | ||
tokenSerializer: common.NewJSONTaskTokenSerializer(), | ||
timeout: timeout, | ||
clients: clients, | ||
client: client, | ||
peer: peerResolver, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: rename peer
to peerResolver
to make it more obvious
What changed?
Client factory used to initialize and cache history clients for each peer. For each client a separate dispatcher was created via rpc factory. This is rather complicated setup and is not idiomatic on YARPC framework.
In order to route requests to different peers, yarpc provides direct peer chooser. It uses
ShardKey
set on the request to route this particular call to the given host. We do not need to initialize multiple dispatchers and multiple clients with caching on top.This PR:
history.PeerChooser
, documents it and adds unit tests.history.Client
to drop client cache and instead addsWithShardKey
for routing to appropriate instance.client.Factory
to wire up new setup.Why?
To move forward towards use of single yarpc dispatcher.
The similar effort is needed for matching client as well. After that we can basically drop rpc.Factory and use single Dispatcher everywhere.
How did you test it?
New unit tests.
Integration tests.
Locally with cadence canary.
Potential risks
This also brings one observable change. History client will no longer use caller name
history-service-client
, but rather use the actual service name where the call is originating, for example:cadence-frontend
.Even though the we can override callerName, at the moment I do not think this is needed. I'm not aware where this could be used other than yarpc metrics.
IMO, the actual name of caller service is more useful than a constant string.
Release notes
Documentation Changes