googleapis / googleapis/google-cloud-java

[sdk-platform-java] Introduce method for configuring response unmarshaller for specified RPC

Offen
#12,452 0 Kommentare 0 Reaktionen 2 zugewiesene Personen Beansprucht von @lqiu96 Auf GitHub ansehen
priority: p2 type: feature request
Vorherrschende Sprache
Java
Sterne
2.1k
Forks
1.2k
Ø Merge
1 T. 23 Std.
Gemergte PRs (30 T.)
154

Beschreibung

**Is your feature request related to a problem? Please describe.**
In Storage SDK (java-storage); we are looking at introducing a new zero copy response marshaler for ReadObject request. It currently can only be configured by recreating the callable which replicates code in the GAPIC generated client library. Our main concern is that it deviates from potential future improvements which would need to be ported over to one-off callable implementations.

```java

// Redacted from constructor where this is being created in the prototype linked below.
serverStreamingCallable =
new GrpcStorageCallableFactory()
.createServerStreamingCallable(
readObjectTransportSettings,
storageClient.getSettings().readObjectSettings(),
ClientContext.create(storageClient.getSettings()));

// ....

static final MethodDescriptor readObjectMethodDescriptor =
MethodDescriptor.newBuilder()
.setType(MethodDescriptor.MethodType.SERVER_STREAMING)
.setFullMethodName("google.storage.v2.Storage/ReadObject")
.setRequestMarshaller(ProtoUtils.marshaller(ReadObjectRequest.getDefaultInstance()))
.setResponseMarshaller(getObjectMediaResponseMarshaller)
.build();

GrpcCallSettings readObjectTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(readObjectMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add(request.getBucket(), "bucket", PathTemplate.create("{bucket=**}"));
return builder.build();
})
.build();
```

**Describe the solution you'd like**
Having a way to configure response unmarshaler for a given RPC in an existing GAPIC client would remove having to maintain this additional code. We currently only need it for ReadObject requests but there will be another RPC soon that will most likely also require this unmarshaler as well.

**Describe alternatives you've considered**
For now we are implementing it this way to unblock zero copy unmarshaler implementation.

**Additional context**
- There's an internal doc on this design that I can share with your team offline.
- Prototype: https://github.com/googleapis/java-storage/pull/2420/

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.