Skip to content

Conversation

@zpencer
Copy link
Contributor

@zpencer zpencer commented Jan 9, 2018

Some changes required to make this work:

  • Fix MethodDescriptor.toBuilder so that it copies all fields
  • It is better to make BinaryLogProvider.provider return null rather than the NullBinaryLogProvider. This is because on client side, the pipeline of interceptors is hard coded when the ManagedChannelImpl is created. It is desirable to avoid inserting a binary logging interceptor shim if we know there is no binary log.

@zpencer zpencer requested a review from ejona86 January 9, 2018 23:22
@zpencer zpencer changed the title ecore: install the binary logging client interceptor core: install the binary logging client interceptor Jan 9, 2018
@zpencer zpencer force-pushed the binarylog-5-clientinterceptor-2-masterdiff branch from cc9eae0 to 1c23481 Compare January 10, 2018 01:16
@@ -0,0 +1,19 @@
syntax = "proto3";
Copy link
Member

Choose a reason for hiding this comment

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

Why was this file added? It seems unused.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops removed

Copy link
Member

@ejona86 ejona86 left a comment

Choose a reason for hiding this comment

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

Still a lot of reviewing left, but sending what I have now.

.setIdempotent(idempotent)
.setSafe(safe)
.setSampledToLocalTracing(sampledToLocalTracing);
.setSampledToLocalTracing(sampledToLocalTracing)
Copy link
Member

Choose a reason for hiding this comment

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

Could you split this bug fix into a separate PR? We may want to backport it, for instance.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Posted #3941, but I'll leave this part alone so the test can work.

return new SimpleForwardingClientCall<ReqT, RespT>(next.newCall(method, callOptions)) {
@Override
public void start(Listener<RespT> responseListener, Metadata headers) {
spyListener = responseListener =
Copy link
Member

Choose a reason for hiding this comment

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

Why this change? I'm happy to kill a spy, but I don't see what it has to do with the rest of the PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Restructuring of ForwardingClientCallListener and PartialForwardingClientCallListener broke the spy, probably because the method we want is now an inherited method.

This works but is less obvious than the non spy():

spy(new SimpleForwardingClientCallListener(responseListener) {
  @Override
  public void onHeaders(Metadata headers) {
    super.onHeaders(headers);
  }
});

Copy link
Member

Choose a reason for hiding this comment

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

It is broken by PartialForwardingClientCallListener being package-private. Making it public fixes it. But it's also fixed if I bump mockito to 2.13.0.

If we use AdditionalAnswers.delegatesTo instead of spy (which is what we should do anywhere we use spy, really), then it starts working:

            spyListener = responseListener =
                mock(ClientCall.Listener.class,
                    delegatesTo(new SimpleForwardingClientCallListener(responseListener) {}));

Although then it can be simplified to:

            spyListener = responseListener =
                mock(ClientCall.Listener.class, delegatesTo(responseListener));

@zpencer zpencer force-pushed the binarylog-5-clientinterceptor-2-masterdiff branch from 5b2137b to 5b02a65 Compare January 25, 2018 17:13
@zpencer
Copy link
Contributor Author

zpencer commented Jan 25, 2018

Rebased against master, resolved conflicts. @ejona86 PTAL

* so the interceptor must be reusable across server calls. At runtime, the request and response
* types passed into the interceptor is always {@link java.io.InputStream}.
* so the interceptor must be reusable across calls. At runtime, the request and response
* marshallers are always {@code Marshaller<Inputstream>}.
Copy link
Member

Choose a reason for hiding this comment

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

s/stream/Stream/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

private static final class IdentityMarshaller implements Marshaller<InputStream> {
@Override
public InputStream stream(InputStream value) {
return value;
Copy link
Member

Choose a reason for hiding this comment

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

Add a TODO to deal with retry?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

- TODO for retry
- methods should be public, for later provider interface
- fix capitalization typo
@zpencer zpencer merged commit 141a1d2 into grpc:master Jan 31, 2018
@zpencer zpencer deleted the binarylog-5-clientinterceptor-2-masterdiff branch January 31, 2018 17:33
@lock lock bot locked as resolved and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants