Skip to content
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

Merged
merged 7 commits into from
May 19, 2024

Conversation

tillrohrmann
Copy link
Contributor

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.

…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
Copy link
Contributor

github-actions bot commented May 16, 2024

Test Results

645 tests   - 21   611 ✅  - 46   2m 14s ⏱️ - 1m 2s
 48 suites ± 0     9 💤 ± 0 
 48 files   ± 0    25 ❌ +25 

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.
dev.restate.e2e.JavaAwaitTimeoutTest ‑ Test Awaitable#await(Duration)
dev.restate.e2e.JavaAwakeableTest ‑ generate(IngressClient)
dev.restate.e2e.JavaCancelInvocationTest ‑ cancel blocked invocation on AWAKEABLE
dev.restate.e2e.JavaCancelInvocationTest ‑ cancel blocked invocation on CALL
dev.restate.e2e.JavaCancelInvocationTest ‑ cancel blocked invocation on SLEEP
dev.restate.e2e.JavaCoordinatorWithNodeReceiverServiceToServiceCallTest ‑ synchronousCall(IngressClient)
dev.restate.e2e.JavaErrorsTest ‑ Test calling method that fails terminally
dev.restate.e2e.JavaErrorsTest ‑ Test calling method that fails terminally multiple times
dev.restate.e2e.JavaErrorsTest ‑ Test invocations are retried until they succeed
dev.restate.e2e.JavaErrorsTest ‑ Test propagate failure from another service
…
dev.restate.e2e.JavaAwaitTimeoutTest ‑ initializationError
dev.restate.e2e.JavaAwakeableTest ‑ initializationError
dev.restate.e2e.JavaCancelInvocationTest ‑ initializationError
dev.restate.e2e.JavaCoordinatorWithNodeReceiverServiceToServiceCallTest ‑ initializationError
dev.restate.e2e.JavaErrorsTest ‑ initializationError
dev.restate.e2e.JavaKafkaIngressTest ‑ initializationError
dev.restate.e2e.JavaRequestSigningTest ‑ initializationError
dev.restate.e2e.JavaSampleWorkflowTest ‑ initializationError
dev.restate.e2e.JavaServiceToServiceCallTest ‑ initializationError
dev.restate.e2e.JavaSimpleSleepTest ‑ initializationError
…

♻️ This comment has been updated with latest results.

@tillrohrmann
Copy link
Contributor Author

The PR is still missing the Lambda handler part.

Comment on lines 29 to 32
HttpRequestFlowAdapter(
HttpServerRequest httpServerRequest, Protocol.ServiceProtocolVersion serviceProtocolVersion) {
assert serviceProtocolVersion == Protocol.ServiceProtocolVersion.V1
: "Unsupported service protocol version";
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor

@slinkydeveloper slinkydeveloper May 17, 2024

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...)

Copy link
Contributor Author

@tillrohrmann tillrohrmann May 17, 2024

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.

Copy link
Contributor Author

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.

Comment on lines 29 to 33
HttpResponseFlowAdapter(
HttpServerResponse httpServerResponse,
Protocol.ServiceProtocolVersion serviceProtocolVersion) {
assert serviceProtocolVersion == Protocol.ServiceProtocolVersion.V1
: "Unsupported service protocol version";
Copy link
Contributor

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.

@tillrohrmann
Copy link
Contributor Author

Thanks for the review @slinkydeveloper. I've addressed your comments and added the support for the lambda case. PTAL.

@tillrohrmann
Copy link
Contributor Author

The CounterTest should be failing because it needs restatedev/restate#1526

Comment on lines 29 to 32
HttpRequestFlowAdapter(
HttpServerRequest httpServerRequest, Protocol.ServiceProtocolVersion serviceProtocolVersion) {
assert serviceProtocolVersion == Protocol.ServiceProtocolVersion.V1
: "Unsupported service protocol version";
Copy link
Contributor

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.

@tillrohrmann
Copy link
Contributor Author

I've tested the e2e tests locally and they passed with restatedev/restate#1526.

Copy link
Contributor

@slinkydeveloper slinkydeveloper left a 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!

…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.
@tillrohrmann
Copy link
Contributor Author

tillrohrmann commented May 19, 2024

Thanks for the review @slinkydeveloper. Merging this PR once GHA gives green light (modulo failing e2e and CounterTest).

@tillrohrmann tillrohrmann merged commit 32e0b7d into restatedev:main May 19, 2024
1 of 4 checks passed
@tillrohrmann tillrohrmann deleted the issues/317 branch May 19, 2024 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integrate Java SDK with service protocol version negotiation
2 participants