Java Code Examples for io.grpc.ForwardingClientCallListener#SimpleForwardingClientCallListener

The following examples show how to use io.grpc.ForwardingClientCallListener#SimpleForwardingClientCallListener . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MySecondClientInterceptor.java    From quarkus with Apache License 2.0 6 votes vote down vote up
@Override
public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall(MethodDescriptor<ReqT, RespT> method,
        CallOptions callOptions, Channel next) {
    return new ForwardingClientCall.SimpleForwardingClientCall<ReqT, RespT>(next.newCall(method, callOptions)) {

        @Override
        public void start(Listener<RespT> responseListener, Metadata headers) {
            super.start(
                    new ForwardingClientCallListener.SimpleForwardingClientCallListener<RespT>(responseListener) {

                        @Override
                        protected Listener<RespT> delegate() {
                            callTime = System.nanoTime();
                            return super.delegate();
                        }
                    }, headers);
        }
    };
}
 
Example 2
Source File: MyFirstClientInterceptor.java    From quarkus with Apache License 2.0 6 votes vote down vote up
@Override
public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall(MethodDescriptor<ReqT, RespT> method,
        CallOptions callOptions, Channel next) {
    return new ForwardingClientCall.SimpleForwardingClientCall<ReqT, RespT>(next.newCall(method, callOptions)) {

        @Override
        public void start(Listener<RespT> responseListener, Metadata headers) {
            super.start(
                    new ForwardingClientCallListener.SimpleForwardingClientCallListener<RespT>(responseListener) {

                        @Override
                        protected Listener<RespT> delegate() {
                            callTime = System.nanoTime();
                            return super.delegate();
                        }
                    }, headers);
        }
    };
}
 
Example 3
Source File: LoggingInterceptor.java    From bazel with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Listener<RespT> responseListener, Metadata headers) {
  entryBuilder.setStartTime(getCurrentTimestamp());
  RequestMetadata metadata = TracingMetadataUtils.requestMetadataFromHeaders(headers);
  if (metadata != null) {
    entryBuilder.setMetadata(metadata);
  }
  super.start(
      new ForwardingClientCallListener.SimpleForwardingClientCallListener<RespT>(
          responseListener) {
        @Override
        public void onMessage(RespT message) {
          handler.handleResp(message);
          super.onMessage(message);
        }

        @Override
        public void onClose(Status status, Metadata trailers) {
          entryBuilder.setEndTime(getCurrentTimestamp());
          entryBuilder.setStatus(makeStatusProto(status));
          entryBuilder.setDetails(handler.getDetails());
          rpcLogFile.write(entryBuilder.build());
          super.onClose(status, trailers);
        }
      },
      headers);
}
 
Example 4
Source File: NetworkTime.java    From bazel with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Listener<RespT> responseListener, Metadata headers) {
  super.start(
      new ForwardingClientCallListener.SimpleForwardingClientCallListener<RespT>(
          responseListener) {

        @Override
        public void onClose(Status status, Metadata trailers) {
          networkTime.stop();
          super.onClose(status, trailers);
        }
      },
      headers);
}