-
Notifications
You must be signed in to change notification settings - Fork 102
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
add(scan): Implement scan
gRPC method
#8268
Conversation
7ee7c93
to
9df6387
Compare
Manual test output with cached results: (There's a duplicate result here, that should be fixed now that the ~/github/zebra$ grpcurl -plaintext -import-path ./zebra-grpc/proto -proto zebra-grpc/proto/scanner.proto -d '{"keys": [{ "key": "zxviews1q0duytgcqqqqpqre26wkl45gvwwwd706xw608hucmvfalr759ejwf7qshjf5r9aa7323zulvz6plhttp5mltqcgs9t039cx2d09mgq05ts63n8u35hyv6h9nc9ctqqtue2u7cer2mqegunuulq2luhq3ywjcz35yyljewa4mgkgjzyfwh6fr6jd0dzd44ghk0nxdv2hnv4j5nxfwv24rwdmgllhe0p8568sgqt9ckt02v2kxf5ahtql6s0ltjpkckw8gtymxtxuu9gcr0swvz", "height": 736000 }]}' '127.0.0.1:8231' scanner.Scanner/Scan
{
"height": 780532,
"results": {
"zxviews1q0duytgcqqqqpqre26wkl45gvwwwd706xw608hucmvfalr759ejwf7qshjf5r9aa7323zulvz6plhttp5mltqcgs9t039cx2d09mgq05ts63n8u35hyv6h9nc9ctqqtue2u7cer2mqegunuulq2luhq3ywjcz35yyljewa4mgkgjzyfwh6fr6jd0dzd44ghk0nxdv2hnv4j5nxfwv24rwdmgllhe0p8568sgqt9ckt02v2kxf5ahtql6s0ltjpkckw8gtymxtxuu9gcr0swvz": {
"txIds": [
"HFGctyvCDQJPnAlUF4QD0W+sfOjbWUrGDbdiE+bIgms="
]
}
}
}
{
"height": 780532,
"results": {
"zxviews1q0duytgcqqqqpqre26wkl45gvwwwd706xw608hucmvfalr759ejwf7qshjf5r9aa7323zulvz6plhttp5mltqcgs9t039cx2d09mgq05ts63n8u35hyv6h9nc9ctqqtue2u7cer2mqegunuulq2luhq3ywjcz35yyljewa4mgkgjzyfwh6fr6jd0dzd44ghk0nxdv2hnv4j5nxfwv24rwdmgllhe0p8568sgqt9ckt02v2kxf5ahtql6s0ltjpkckw8gtymxtxuu9gcr0swvz": {
"txIds": [
"HFGctyvCDQJPnAlUF4QD0W+sfOjbWUrGDbdiE+bIgms="
]
}
}
}
{
"height": 780616,
"results": {
"zxviews1q0duytgcqqqqpqre26wkl45gvwwwd706xw608hucmvfalr759ejwf7qshjf5r9aa7323zulvz6plhttp5mltqcgs9t039cx2d09mgq05ts63n8u35hyv6h9nc9ctqqtue2u7cer2mqegunuulq2luhq3ywjcz35yyljewa4mgkgjzyfwh6fr6jd0dzd44ghk0nxdv2hnv4j5nxfwv24rwdmgllhe0p8568sgqt9ckt02v2kxf5ahtql6s0ltjpkckw8gtymxtxuu9gcr0swvz": {
"txIds": [
"nvIywWt5HlwTwGcRV3bc+hVEsYMEAa8cKCiGymOVZ54="
]
}
}
}
..
^C Output without cached results: ~/github/zebra$ grpcurl -plaintext -import-path ./zebra-grpc/proto -proto zebra-grpc/proto/scanner.proto -d '{"keys": [{ "key": "zxviews1q0duytgcqqqqpqre26wkl45gvwwwd706xw608hucmvfalr759ejwf7qshjf5r9aa7323zulvz6plhttp5mltqcgs9t039cx2d09mgq05ts63n8u35hyv6h9nc9ctqqtue2u7cer2mqegunuulq2luhq3ywjcz35yyljewa4mgkgjzyfwh6fr6jd0dzd44ghk0nxdv2hnv4j5nxfwv24rwdmgllhe0p8568sgqt9ckt02v2kxf5ahtql6s0ltjpkckw8gtymxtxuu9gcr0swvz", "height": 736000 }]}' '127.0.0.1:8231' scanner.Scanner/Scan
{
"height": 780532,
"results": {
"zxviews1q0duytgcqqqqpqre26wkl45gvwwwd706xw608hucmvfalr759ejwf7qshjf5r9aa7323zulvz6plhttp5mltqcgs9t039cx2d09mgq05ts63n8u35hyv6h9nc9ctqqtue2u7cer2mqegunuulq2luhq3ywjcz35yyljewa4mgkgjzyfwh6fr6jd0dzd44ghk0nxdv2hnv4j5nxfwv24rwdmgllhe0p8568sgqt9ckt02v2kxf5ahtql6s0ltjpkckw8gtymxtxuu9gcr0swvz": {
"txIds": [
"HFGctyvCDQJPnAlUF4QD0W+sfOjbWUrGDbdiE+bIgms="
]
}
}
}
{
"height": 780616,
"results": {
"zxviews1q0duytgcqqqqpqre26wkl45gvwwwd706xw608hucmvfalr759ejwf7qshjf5r9aa7323zulvz6plhttp5mltqcgs9t039cx2d09mgq05ts63n8u35hyv6h9nc9ctqqtue2u7cer2mqegunuulq2luhq3ywjcz35yyljewa4mgkgjzyfwh6fr6jd0dzd44ghk0nxdv2hnv4j5nxfwv24rwdmgllhe0p8568sgqt9ckt02v2kxf5ahtql6s0ltjpkckw8gtymxtxuu9gcr0swvz": {
"txIds": [
"nvIywWt5HlwTwGcRV3bc+hVEsYMEAa8cKCiGymOVZ54="
]
}
}
}
{
"height": 780773,
"results": {
"zxviews1q0duytgcqqqqpqre26wkl45gvwwwd706xw608hucmvfalr759ejwf7qshjf5r9aa7323zulvz6plhttp5mltqcgs9t039cx2d09mgq05ts63n8u35hyv6h9nc9ctqqtue2u7cer2mqegunuulq2luhq3ywjcz35yyljewa4mgkgjzyfwh6fr6jd0dzd44ghk0nxdv2hnv4j5nxfwv24rwdmgllhe0p8568sgqt9ckt02v2kxf5ahtql6s0ltjpkckw8gtymxtxuu9gcr0swvz": {
"txIds": [
"uTuqs07MXG4huksWBwWB1ccrGzjX4SG+UWZPPPBCVxM="
]
}
}
}
.. |
6c0b1cf
to
ddc4318
Compare
dd95bc3
to
9857e9e
Compare
For the manual test i think it will be nice if we can show that we are listening and that a new transaction gets in. |
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.
I was expecting a method subscribe
that will subscribe to an already registered key but i think this method is even better as it kind of do everything.
I am wondering if we should also have a subscribe
method that just subscribe to the stream of an already registered key.
Added:
It feels the method covers too much so it kind of leave obsolete other methods that we need to maintain if we keep.
I did, that's the second console output, I deleted the key, added it back, waited a bit, and hit ctrl-C after seeing a few results.
Do you have a use case or motivation in mind? I'm thinking clients probably want the results whether their key is registered or not, so it feels redundant.
This method is a push interface, the pull interface is useful for clients that are calling the RPC methods from a browser environment, or for usability if some clients find it simpler to use the pull interface. The RPC methods are only thin wrappers around the service requests, so there shouldn't be much of a maintenance burden to supporting both. |
Ok, thanks for the clarification.
This makes all that in one step, which i think it can be fine but i don't remember it was planned this way.
I don't remember that we planned to have 2 different interfaces (with overlapping functionality).
It is more easy to add than to remove. Once you support an api call you make a commit to support it (otherwise applications will break). You can have deprecation policies, etc but in general you need to keep them. I don't mind adding this call, i just think it do a lot more than needed. |
I'll wait for #8277 to merge then rebase and update/add the snapshots. |
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.
Looks great, thank you for the changes. Can you update the manual tests to show the new output format ? The other option is to add the snapshots, whatever is easier for you.
I'll try adding the snapshots, since we need to do that anyways. |
02873fa
to
2060c25
Compare
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.
Looks good, thank for adding the snapshots here.
* Adds scan method * fix clippy warning * Skip empty results and don't panic if the gRPC client disconnects * moves `Results` request above `SubscribeResults` request to avoid duplicate results. * returns early if there's a send error when sending initial results and updates response type * move responder buffer size to const * Adds a snapshot test for the `scan` method * updates snapshots
Motivation
We want to provide a streaming method for registering keys, getting cached scan results, and listening for any new scan results.
Closes #8256.
PR Author Checklist
Check before marking the PR as ready for review:
For significant changes:
If a checkbox isn't relevant to the PR, mark it as done.
Solution
ScanService
withRegisterKeys
,Results
andSubscribeResults
requestsresponse
channelReceiverStream
wrapper around the response receiverResults
response and sends them to the response channelresults_receiver
returned by the call toSubscribeResults
and sends them to the response channelReview
Anyone can review.
Reviewer Checklist
Check before approving the PR:
PR blockers can be dealt with in new tickets or PRs.
And check the PR Author checklist is complete.