-
Notifications
You must be signed in to change notification settings - Fork 5
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
Integrate Java SDK with new service protocol negotiation mechanism #318
Conversation
…1898426 1898426 Update min/max of protocol version fields in endpoint_manifest_schema 08871e0 Introduce service.Version and discovery.Version enums 2f3e461 Workflow api changes (restatedev#91) 1fa71a5 Add versioning info (restatedev#90) git-subtree-dir: sdk-core/src/main/service-protocol git-subtree-split: 1898426fc98c16d704068594cd54394912845ff7
Test Results645 tests - 21 611 ✅ - 46 2m 14s ⏱️ - 1m 2s For more details on these failures, see this check. Results for commit 32e0b7d. ± Comparison against base commit 1c4b4e7. This pull request removes 44 and adds 23 tests. Note that renamed tests count towards both.
♻️ This comment has been updated with latest results. |
The PR is still missing the Lambda handler part. |
HttpRequestFlowAdapter( | ||
HttpServerRequest httpServerRequest, Protocol.ServiceProtocolVersion serviceProtocolVersion) { | ||
assert serviceProtocolVersion == Protocol.ServiceProtocolVersion.V1 | ||
: "Unsupported service protocol version"; |
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.
Not sure why we need this assert here. I would remove it.
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.
The idea is to make bumping the service protocol version a conscious decision which might need to touch the encoder/decoder as well.
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've changed it into a IllegalArgumentException
.
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.
Not sure this helps, when you bump the protocol you need to do it in the endpoint already, this just adds another point to touch when bumping. Also this class it's a package private class anyway, and only instantiated in the endpoint class.
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.
Also this piece of code most likely won't change with next protocol updates, but only the internal encoders/decoders. If it will, it's a big enough change that we won't forget to update the request handlers. On the other side, we will most likely forget updating these assertions here (for lambda even worse, we don't have automated tests that check the lambda sdks work fine...)
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.
This would be the place where one passes the serviceProtocolVersion
to the encoder/decoders, I guess. Atm they only support V1 so I didn't bother to pass it through. If you like, then I can also do this instead.
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've removed this check from the code.
HttpResponseFlowAdapter( | ||
HttpServerResponse httpServerResponse, | ||
Protocol.ServiceProtocolVersion serviceProtocolVersion) { | ||
assert serviceProtocolVersion == Protocol.ServiceProtocolVersion.V1 | ||
: "Unsupported service protocol version"; |
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.
Not sure why we need this assert here. I would remove it.
sdk-http-vertx/src/main/java/dev/restate/sdk/http/vertx/RequestHttpServerHandler.java
Outdated
Show resolved
Hide resolved
sdk-http-vertx/src/main/java/dev/restate/sdk/http/vertx/RequestHttpServerHandler.java
Outdated
Show resolved
Hide resolved
sdk-http-vertx/src/main/java/dev/restate/sdk/http/vertx/RequestHttpServerHandler.java
Outdated
Show resolved
Hide resolved
sdk-http-vertx/src/main/java/dev/restate/sdk/http/vertx/RequestHttpServerHandler.java
Outdated
Show resolved
Hide resolved
Thanks for the review @slinkydeveloper. I've addressed your comments and added the support for the lambda case. PTAL. |
The |
sdk-http-vertx/src/main/java/dev/restate/sdk/http/vertx/RequestHttpServerHandler.java
Outdated
Show resolved
Hide resolved
HttpRequestFlowAdapter( | ||
HttpServerRequest httpServerRequest, Protocol.ServiceProtocolVersion serviceProtocolVersion) { | ||
assert serviceProtocolVersion == Protocol.ServiceProtocolVersion.V1 | ||
: "Unsupported service protocol version"; |
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.
Not sure this helps, when you bump the protocol you need to do it in the endpoint already, this just adds another point to touch when bumping. Also this class it's a package private class anyway, and only instantiated in the endpoint class.
a1ce667
to
b28ac1f
Compare
I've tested the e2e tests locally and they passed with restatedev/restate#1526. |
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 so much for taking care of this!
sdk-lambda/src/main/java/dev/restate/sdk/lambda/LambdaFlowAdapters.java
Outdated
Show resolved
Hide resolved
sdk-lambda/src/main/java/dev/restate/sdk/lambda/LambdaFlowAdapters.java
Outdated
Show resolved
Hide resolved
…aders This commit lets the Java SDK extract the accepted ServiceDiscoveryProtocolVersions from the accept header of the discovery request and sends a correspondingly encoded response back if the endpoint supports the service discovery protocol version. Likewise the SDK is now extracting the service protocol version from the content type header when the service is invoked. If the endpoint does not support the specified protocol version, then it will reject the request with a status code 415.
We are no longer sending the protocol version via the message headers of the start message. This commit removes this logic. This fixes restatedev#317.
Thanks for the review @slinkydeveloper. Merging this PR once GHA gives green light (modulo failing e2e and |
This commit lets the Java SDK extract the accepted ServiceDiscoveryProtocolVersions
from the accept header of the discovery request and sends a correspondingly encoded
response back if the endpoint supports the service discovery protocol version.
Likewise the SDK is now extracting the service protocol version from the content type
header when the service is invoked. If the endpoint does not support the specified
protocol version, then it will reject the request with a status code 415.
We are no longer sending the protocol version via the message headers
of the start message. This commit removes this logic.
This fixes #317.