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

fix: support metadata in deferred calls execution #1724

Merged
merged 13 commits into from
Jul 11, 2023

Conversation

aludwiko
Copy link
Contributor

References #1702

@aludwiko aludwiko linked an issue Jun 30, 2023 that may be closed by this pull request
@github-actions github-actions bot added Documentation Improvements or additions to the documentation java-sdk java-sdk-protobuf kalix-runtime Runtime and SDKs sub-team scala-sdk-protobuf labels Jun 30, 2023
| private <Req, Res> SingleResponseRequestBuilder<Req, Res> addHeaders(SingleResponseRequestBuilder<Req, Res> requestBuilder, Metadata metadata){
| var updatedBuilder = requestBuilder;
| for (Metadata.MetadataEntry entry: metadata){
| if (entry.isText()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, maybe for grpc based sdk, I should support binary headers as well?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can skip those for now.

@@ -47,7 +48,7 @@ public void tearDown() throws Exception {
// tag::initialize[]
@Test
public void initializeCartTest() throws ExecutionException, InterruptedException, TimeoutException {
when(shoppingCartService.create(notNull()))
when(shoppingCartService.create().invoke(notNull()))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Under the hood we have:

(Metadata metadata) -> addHeaders(((com.example.shoppingcart.ShoppingCartServiceClient) getGrpcClient(com.example.shoppingcart.ShoppingCartService.class)).create(), metadata).invoke(createCart)

thanks to RETURNS_DEEP_STUBS I was able to fix it in the java version, but with mockito scala I'm not sure if this is an option.

Maybe we shouldn't encourage users to write unit tests for side effects. Personally I would go with IT tests for such cases.

Copy link
Member

@octonato octonato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@aludwiko aludwiko merged commit 74aceaf into main Jul 11, 2023
65 checks passed
@aludwiko aludwiko deleted the 1702-support-metadata-in-deferred-calls-execution branch July 11, 2023 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Improvements or additions to the documentation java-sdk java-sdk-protobuf kalix-runtime Runtime and SDKs sub-team scala-sdk-protobuf
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support metadata in deferred calls execution
3 participants