generated from microsoft/ccf-app-template
-
Notifications
You must be signed in to change notification settings - Fork 6
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
Watches #186
Draft
jeffa5
wants to merge
15
commits into
main
Choose a base branch
from
server-streaming
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Watches #186
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
d7464b4
Update ccf gRPC endpoint header
1148249
Add etcd watch request and response proto definitions
9f3a585
Add watch logic
a119394
Log ccf dir
7f65143
Update includes for rebased streaming and close stream in created res…
5eadabe
New API
cafd16f
Works
50fd0b9
Watches for single key (put only)
ca4e413
ccf.patch
b52603f
Merge branch 'main' of github.com:microsoft/LSKV into server-streaming
e212340
.
38d82b1
..
1c9da63
Merge branch 'main' into server-streaming
ea40a6c
Fix
c342f86
Patch
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
diff --git a/src/endpoints/grpc/grpc.h b/src/endpoints/grpc/grpc.h | ||
index bf7829feb..c29fa47ad 100644 | ||
--- a/src/endpoints/grpc/grpc.h | ||
+++ b/src/endpoints/grpc/grpc.h | ||
@@ -68,22 +68,30 @@ namespace ccf::grpc | ||
} | ||
else | ||
{ | ||
- const auto message_length = impl::read_message_frame(data, size); | ||
- if (size != message_length) | ||
+ In in; | ||
+ try | ||
{ | ||
- throw std::logic_error(fmt::format( | ||
- "Error in gRPC frame: frame size is {} but messages is {} bytes", | ||
- size, | ||
- message_length)); | ||
- } | ||
+ const auto message_length = impl::read_message_frame(data, size); | ||
+ if (size != message_length) | ||
+ { | ||
+ throw std::logic_error(fmt::format( | ||
+ "Error in gRPC frame: frame size is {} but messages is {} bytes", | ||
+ size, | ||
+ message_length)); | ||
+ } | ||
|
||
- In in; | ||
- if (!in.ParseFromArray(data, message_length)) | ||
+ if (!in.ParseFromArray(data, message_length)) | ||
+ { | ||
+ throw std::logic_error(fmt::format( | ||
+ "Error deserialising protobuf payload of type {}, size {}", | ||
+ in.GetTypeName(), | ||
+ size)); | ||
+ } | ||
+ } | ||
+ catch (const std::exception& e) | ||
{ | ||
- throw std::logic_error(fmt::format( | ||
- "Error deserialising protobuf payload of type {}, size {}", | ||
- in.GetTypeName(), | ||
- size)); | ||
+ // Note: Client streaming! | ||
+ LOG_FAIL_FMT("Error deserialising payload: {}", e.what()); | ||
} | ||
return in; | ||
} | ||
diff --git a/src/http/http2_callbacks.h b/src/http/http2_callbacks.h | ||
index 45634231c..d7d46ca44 100644 | ||
--- a/src/http/http2_callbacks.h | ||
+++ b/src/http/http2_callbacks.h | ||
@@ -36,7 +36,7 @@ namespace http2 | ||
stream_data->outgoing.state == StreamResponseState::Streaming) | ||
{ | ||
// Early out: when streaming, avoid calling this callback | ||
- // repeatedly when there no data to read | ||
+ // repeatedly when there is no data to read | ||
return NGHTTP2_ERR_DEFERRED; | ||
} | ||
|
||
@@ -122,8 +122,20 @@ namespace http2 | ||
return 0; | ||
} | ||
|
||
+ auto& headers = stream_data->incoming.headers; | ||
+ std::string url = {}; | ||
+ { | ||
+ const auto url_it = headers.find(http2::headers::PATH); | ||
+ if (url_it != headers.end()) | ||
+ { | ||
+ url = url_it->second; | ||
+ } | ||
+ } | ||
+ | ||
// If the request is complete, process it | ||
- if (frame->hd.flags & NGHTTP2_FLAG_END_STREAM) | ||
+ if ( | ||
+ frame->hd.flags & NGHTTP2_FLAG_END_STREAM || | ||
+ url == "/etcdserverpb.Watch/Watch") | ||
{ | ||
auto* p = get_parser(user_data); | ||
p->handle_completed(stream_id, stream_data); | ||
diff --git a/src/http/http2_parser.h b/src/http/http2_parser.h | ||
index 4e5b91a33..a4b808b8a 100644 | ||
--- a/src/http/http2_parser.h | ||
+++ b/src/http/http2_parser.h | ||
@@ -387,8 +387,11 @@ namespace http2 | ||
|
||
if (stream_data->outgoing.state != StreamResponseState::Uninitialised) | ||
{ | ||
- throw std::logic_error(fmt::format( | ||
- "Stream {} should be uninitialised to start stream", stream_id)); | ||
+ // throw std::logic_error(fmt::format( | ||
+ // "Stream {} should be uninitialised to start stream", stream_id)); | ||
+ | ||
+ stream_data->outgoing.state = StreamResponseState::Streaming; | ||
+ return; | ||
} | ||
|
||
stream_data->outgoing.state = StreamResponseState::Streaming; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@jumaffre I guess for lease keep alives (also bidi) we'd need to add that path here too?
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.
Yes, as long as client streaming isn't supported in CCF.