-
Notifications
You must be signed in to change notification settings - Fork 265
mockstore: implement LoadKeyspaceByID in PD mocks #2016
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,7 @@ | |
| "github.com/tikv/client-go/v2/util/async" | ||
| pd "github.com/tikv/pd/client" | ||
| "github.com/tikv/pd/client/clients/gc" | ||
| "github.com/tikv/pd/client/clients/metastorage" | ||
| "github.com/tikv/pd/client/clients/router" | ||
| "github.com/tikv/pd/client/clients/tso" | ||
| "github.com/tikv/pd/client/opt" | ||
|
|
@@ -254,6 +255,11 @@ | |
| panic("unimplemented") | ||
| } | ||
|
|
||
| // LoadKeyspaceByID implements pd.Client. | ||
| func (u *unimplementedPDClient) LoadKeyspaceByID(ctx context.Context, id uint32) (*keyspacepb.KeyspaceMeta, error) { | ||
| panic("unimplemented") | ||
| } | ||
|
|
||
| // LoadResourceGroups implements pd.Client. | ||
| func (u *unimplementedPDClient) LoadResourceGroups(ctx context.Context) ([]*resource_manager.ResourceGroup, int64, error) { | ||
| panic("unimplemented") | ||
|
|
@@ -335,7 +341,7 @@ | |
| } | ||
|
|
||
| // Watch implements pd.Client. | ||
| func (u *unimplementedPDClient) Watch(ctx context.Context, key []byte, opts ...opt.MetaStorageOption) (chan []*meta_storagepb.Event, error) { | ||
| func (u *unimplementedPDClient) Watch(ctx context.Context, key []byte, opts ...opt.MetaStorageOption) (chan *metastorage.WatchResponse, error) { | ||
|
Check failure on line 344 in txnkv/transaction/test_util.go
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🔴 Critical | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
# Locate the file and nearby references
git ls-files | rg '^txnkv/transaction/test_util\.go$|^internal/mockstore/mocktikv/pd\.go$|metastorage\.WatchResponse|WatchResponse|MetaStorageOption'
# Show the relevant section of txnkv/transaction/test_util.go
if [ -f txnkv/transaction/test_util.go ]; then
sed -n '300,380p' txnkv/transaction/test_util.go
fi
# Show the relevant section of internal/mockstore/mocktikv/pd.go if present
if [ -f internal/mockstore/mocktikv/pd.go ]; then
sed -n '1,220p' internal/mockstore/mocktikv/pd.go
fi
# Search for the Watch method and WatchResponse type usages across the repo
rg -n "func \(u \*unimplementedPDClient\) Watch|metastorage\.WatchResponse|type WatchResponse|WatchResponse" .Repository: tikv/client-go Length of output: 11025 🏁 Script executed: set -euo pipefail
# Show the pd/client version pinned by this repo
rg -n 'github.com/tikv/pd/client|github.com/tikv/pd' go.mod go.sum
# Search for any local references to metastorage.WatchResponse or WatchResponse
rg -n 'metastorage\.WatchResponse|type WatchResponse|WatchResponse' .
# Inspect the pd.Client-facing watch methods around the mock implementation
sed -n '470,520p' internal/mockstore/mocktikv/pd.go
sed -n '330,360p' txnkv/transaction/test_util.goRepository: tikv/client-go Length of output: 3925 🏁 Script executed: set -euo pipefail
echo "GOMODCACHE=$(go env GOMODCACHE)"
echo "GOPATH=$(go env GOPATH)"
modcache="$(go env GOMODCACHE)"
pdroot="$modcache/github.com/tikv/pd/client@v0.0.0-20260601035915-3ef6a3b10c84"
if [ -d "$pdroot" ]; then
echo "FOUND_MODULE_CACHE=$pdroot"
rg -n "type WatchResponse|WatchResponse" "$pdroot"/clients/metastorage "$pdroot"/clients -g'*.go'
sed -n '1,220p' "$pdroot"/clients/metastorage/*.go 2>/dev/null || true
else
echo "Module cache directory not found: $pdroot"
fiRepository: tikv/client-go Length of output: 320 🏁 Script executed: set -euo pipefail
modcache="$(go env GOMODCACHE)"
pdroot="$modcache/github.com/tikv/pd/client@v0.0.0-20260601035915-3ef6a3b10c84"
echo "Files under clients/metastorage:"
find "$pdroot/clients/metastorage" -maxdepth 2 -type f | sort
echo
echo "Search for WatchResponse and package declarations:"
rg -n "type WatchResponse|WatchResponse|package " "$pdroot/clients/metastorage" -g'*.go'
echo
echo "Show the metastorage files:"
for f in "$pdroot"/clients/metastorage/*.go; do
echo "---- $f ----"
sed -n '1,220p' "$f"
doneRepository: tikv/client-go Length of output: 3805 Use
🧰 Tools🪛 GitHub Check: test[failure] 344-344: 🤖 Prompt for AI AgentsSources: Linters/SAST tools, Pipeline failures |
||
| panic("unimplemented") | ||
| } | ||
|
|
||
|
|
||
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.
🗄️ Data Integrity & Integration | 🔴 Critical | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: tikv/client-go
Length of output: 152
🏁 Script executed:
Repository: tikv/client-go
Length of output: 15244
🌐 Web query:
github.com/tikv/pd/client metastorage WatchResponse exported type watch response💡 Result:
In the TiKV and PD (Placement Driver) ecosystem, WatchResponse is an exported type originating from the
kvprotorepository [1][2], specifically defined within themeta_storagepbpackage. While the PD Go client (github.com/tikv/pd/client) interacts with PD,WatchResponseis primarily associated with the gRPC-based Meta Storage API used for watching changes to meta data [1][2]. In the TiKV Rust client implementation,WatchResponseis used as part of the streaming response when a watch request is initiated against the Meta Storage service [1][2]. Key points regarding the usage of WatchResponse: - Definition: It is a protobuf-generated message type defined inkvprotoundermeta_storagepb[1][2]. - Usage: It is utilized in streaming RPC calls (e.g., in Rust, it is returned viagrpcio::ClientSStreamReceiver<WatchResponse>) to handle updates or events related to watched keys or paths [1][2]. - Go Client Context: While the Go client library provides methods likeWatchGlobalConfig[3], it manages its own internal channels and response types (e.g.,GlobalConfigItem) rather than directly exposing themeta_storagepb.WatchResponsetype to the high-level application developer interface [3]. If you are working directly with the generated gRPC client in Go, you would import it from the generatedmeta_storagepbpackage [1][2]. If you are encountering issues withWatchResponse(such as memory management or channel handling), developers often look at the underlying gRPC stream processing, as errors in the stream are typically accessible via theErr()method on the response object or during the stream consumption process [4].Citations:
🏁 Script executed:
Repository: tikv/client-go
Length of output: 808
🏁 Script executed:
Repository: tikv/client-go
Length of output: 4496
Replace
metastorage.WatchResponsewith[]*meta_storagepb.Eventgithub.com/tikv/pd/client@v0.0.0-20260601035915-3ef6a3b10c84exposesWatch(ctx, ...) (chan []*meta_storagepb.Event, error)inclients/metastorage, so both this mock andtxnkv/transaction/test_util.goshould use that element type.🧰 Tools
🪛 GitHub Check: golangci
[failure] 494-494:
undefined: metastorage.WatchResponse (typecheck)
🪛 GitHub Check: test
[failure] 494-494:
undefined: metastorage.WatchResponse
🤖 Prompt for AI Agents
Sources: Linters/SAST tools, Pipeline failures