Skip to content

Commit

Permalink
hrpc: Add QueueBatch to the RegionClient interface
Browse files Browse the repository at this point in the history
Removes a type assert in SendBatch.
  • Loading branch information
aaronbee committed Jul 27, 2023
1 parent 4e81719 commit 3acbbb4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions hrpc/call.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type RegionClient interface {
Close()
Addr() string
QueueRPC(Call)
QueueBatch(context.Context, []Call)
String() string
}

Expand Down
7 changes: 1 addition & 6 deletions rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,14 +250,9 @@ func (c *client) SendBatch(ctx context.Context, batch []hrpc.Call) (
)
wg.Add(len(rpcByClient))
for client, rpcs := range rpcByClient {
// TODO: Move this to the RegionClient interface so we don't
// need to type assert here
qb := client.(interface {
QueueBatch(ctx context.Context, rpcs []hrpc.Call)
})
go func(client hrpc.RegionClient, rpcs []hrpc.Call) {
defer wg.Done()
qb.QueueBatch(ctx, rpcs)
client.QueueBatch(ctx, rpcs)
ctx, sp := observability.StartSpan(ctx, "waitForResult")
defer sp.End()
ok := c.waitForCompletion(ctx, client, rpcs, res, rpcToRes)
Expand Down
12 changes: 12 additions & 0 deletions test/mock/region/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3acbbb4

Please sign in to comment.