Skip to content

Commit 40207ef

Browse files
committed
refactor(gax): add startUnaryCall to HttpJsonClientCalls
1 parent 386b544 commit 40207ef

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

sdk-platform-java/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpJsonClientCalls.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@ static HttpJsonMetadata getMetadataWithTraceContext(HttpJsonCallContext context)
9494
return HttpJsonMetadata.newBuilder().build().withHeaders(finalHeaders);
9595
}
9696

97-
static <RequestT, ResponseT> ApiFuture<ResponseT> futureUnaryCall(
97+
static <RequestT, ResponseT> void startUnaryCall(
9898
HttpJsonClientCall<RequestT, ResponseT> clientCall,
9999
RequestT request,
100-
HttpJsonCallContext context) {
100+
HttpJsonCallContext context,
101+
HttpJsonClientCall.Listener<ResponseT> listener) {
101102
// Start the call
102-
HttpJsonFuture<ResponseT> future = new HttpJsonFuture<>(clientCall);
103-
clientCall.start(new FutureListener<>(future), getMetadataWithTraceContext(context));
103+
clientCall.start(listener, getMetadataWithTraceContext(context));
104104

105105
// Send the request
106106
try {
@@ -118,7 +118,15 @@ static <RequestT, ResponseT> ApiFuture<ResponseT> futureUnaryCall(
118118

119119
throw sendError;
120120
}
121+
}
121122

123+
static <RequestT, ResponseT> ApiFuture<ResponseT> futureUnaryCall(
124+
HttpJsonClientCall<RequestT, ResponseT> clientCall,
125+
RequestT request,
126+
HttpJsonCallContext context) {
127+
// Start the call
128+
HttpJsonFuture<ResponseT> future = new HttpJsonFuture<>(clientCall);
129+
startUnaryCall(clientCall, request, context, new FutureListener<>(future));
122130
return future;
123131
}
124132

0 commit comments

Comments
 (0)