-
Notifications
You must be signed in to change notification settings - Fork 67
feat: enable selective generation based on service config include list #3323
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
4a75bfd
feat: selective generation based on service config include list.
zhumin8 1f5be4b
fix merging mistake and lint.
zhumin8 ec21a3b
add comment and add assert to test to verify correct methods included.
zhumin8 7549824
revert inline mockito usage it breaks for JDK 21. Create service obj …
zhumin8 91eddd5
lint.
zhumin8 1d09388
update comments.
zhumin8 74e729e
extract method to determine empty service.
zhumin8 b7c4a1e
lint.
zhumin8 4121b5e
remove golden test because it is only showing results in a more obvio…
zhumin8 1ce3656
feedback: add comments.
zhumin8 79ec16e
Merge branch 'main' into selective-api-v1
zhumin8 cf14f15
removed unused method. address sonar issue.
zhumin8 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
197 changes: 197 additions & 0 deletions
197
...t/java/com/google/api/generator/gapic/composer/grpc/goldens/SelectiveGeneratedStub.golden
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
package com.google.selective.generate.v1beta1.stub; | ||
|
||
import com.google.api.core.BetaApi; | ||
import com.google.api.gax.core.BackgroundResource; | ||
import com.google.api.gax.core.BackgroundResourceAggregation; | ||
import com.google.api.gax.grpc.GrpcCallSettings; | ||
import com.google.api.gax.grpc.GrpcStubCallableFactory; | ||
import com.google.api.gax.rpc.BidiStreamingCallable; | ||
import com.google.api.gax.rpc.ClientContext; | ||
import com.google.api.gax.rpc.UnaryCallable; | ||
import com.google.longrunning.stub.GrpcOperationsStub; | ||
import com.google.selective.generate.v1beta1.EchoRequest; | ||
import com.google.selective.generate.v1beta1.EchoResponse; | ||
import io.grpc.MethodDescriptor; | ||
import io.grpc.protobuf.ProtoUtils; | ||
import java.io.IOException; | ||
import java.util.concurrent.TimeUnit; | ||
import javax.annotation.Generated; | ||
|
||
// AUTO-GENERATED DOCUMENTATION AND CLASS. | ||
/** | ||
* gRPC stub implementation for the EchoServiceShouldGeneratePartial service API. | ||
* | ||
* <p>This class is for advanced usage and reflects the underlying API directly. | ||
*/ | ||
@BetaApi | ||
@Generated("by gapic-generator-java") | ||
public class GrpcEchoServiceShouldGeneratePartialStub extends EchoServiceShouldGeneratePartialStub { | ||
private static final MethodDescriptor<EchoRequest, EchoResponse> | ||
echoShouldIncludeMethodDescriptor = | ||
MethodDescriptor.<EchoRequest, EchoResponse>newBuilder() | ||
.setType(MethodDescriptor.MethodType.UNARY) | ||
.setFullMethodName( | ||
"google.selective.generate.v1beta1.EchoServiceShouldGeneratePartial/EchoShouldInclude") | ||
.setRequestMarshaller(ProtoUtils.marshaller(EchoRequest.getDefaultInstance())) | ||
.setResponseMarshaller(ProtoUtils.marshaller(EchoResponse.getDefaultInstance())) | ||
.build(); | ||
|
||
private static final MethodDescriptor<EchoRequest, EchoResponse> | ||
chatShouldIncludeMethodDescriptor = | ||
MethodDescriptor.<EchoRequest, EchoResponse>newBuilder() | ||
.setType(MethodDescriptor.MethodType.BIDI_STREAMING) | ||
.setFullMethodName( | ||
"google.selective.generate.v1beta1.EchoServiceShouldGeneratePartial/ChatShouldInclude") | ||
.setRequestMarshaller(ProtoUtils.marshaller(EchoRequest.getDefaultInstance())) | ||
.setResponseMarshaller(ProtoUtils.marshaller(EchoResponse.getDefaultInstance())) | ||
.build(); | ||
|
||
private static final MethodDescriptor<EchoRequest, EchoResponse> | ||
chatAgainShouldIncludeMethodDescriptor = | ||
MethodDescriptor.<EchoRequest, EchoResponse>newBuilder() | ||
.setType(MethodDescriptor.MethodType.BIDI_STREAMING) | ||
.setFullMethodName( | ||
"google.selective.generate.v1beta1.EchoServiceShouldGeneratePartial/ChatAgainShouldInclude") | ||
.setRequestMarshaller(ProtoUtils.marshaller(EchoRequest.getDefaultInstance())) | ||
.setResponseMarshaller(ProtoUtils.marshaller(EchoResponse.getDefaultInstance())) | ||
.build(); | ||
|
||
private final UnaryCallable<EchoRequest, EchoResponse> echoShouldIncludeCallable; | ||
private final BidiStreamingCallable<EchoRequest, EchoResponse> chatShouldIncludeCallable; | ||
private final BidiStreamingCallable<EchoRequest, EchoResponse> chatAgainShouldIncludeCallable; | ||
|
||
private final BackgroundResource backgroundResources; | ||
private final GrpcOperationsStub operationsStub; | ||
private final GrpcStubCallableFactory callableFactory; | ||
|
||
public static final GrpcEchoServiceShouldGeneratePartialStub create( | ||
EchoServiceShouldGeneratePartialStubSettings settings) throws IOException { | ||
return new GrpcEchoServiceShouldGeneratePartialStub(settings, ClientContext.create(settings)); | ||
} | ||
|
||
public static final GrpcEchoServiceShouldGeneratePartialStub create(ClientContext clientContext) | ||
throws IOException { | ||
return new GrpcEchoServiceShouldGeneratePartialStub( | ||
EchoServiceShouldGeneratePartialStubSettings.newBuilder().build(), clientContext); | ||
} | ||
|
||
public static final GrpcEchoServiceShouldGeneratePartialStub create( | ||
ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { | ||
return new GrpcEchoServiceShouldGeneratePartialStub( | ||
EchoServiceShouldGeneratePartialStubSettings.newBuilder().build(), | ||
clientContext, | ||
callableFactory); | ||
} | ||
|
||
/** | ||
* Constructs an instance of GrpcEchoServiceShouldGeneratePartialStub, using the given settings. | ||
* This is protected so that it is easy to make a subclass, but otherwise, the static factory | ||
* methods should be preferred. | ||
*/ | ||
protected GrpcEchoServiceShouldGeneratePartialStub( | ||
EchoServiceShouldGeneratePartialStubSettings settings, ClientContext clientContext) | ||
throws IOException { | ||
this(settings, clientContext, new GrpcEchoServiceShouldGeneratePartialCallableFactory()); | ||
} | ||
|
||
/** | ||
* Constructs an instance of GrpcEchoServiceShouldGeneratePartialStub, using the given settings. | ||
* This is protected so that it is easy to make a subclass, but otherwise, the static factory | ||
* methods should be preferred. | ||
*/ | ||
protected GrpcEchoServiceShouldGeneratePartialStub( | ||
EchoServiceShouldGeneratePartialStubSettings settings, | ||
ClientContext clientContext, | ||
GrpcStubCallableFactory callableFactory) | ||
throws IOException { | ||
this.callableFactory = callableFactory; | ||
this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); | ||
|
||
GrpcCallSettings<EchoRequest, EchoResponse> echoShouldIncludeTransportSettings = | ||
GrpcCallSettings.<EchoRequest, EchoResponse>newBuilder() | ||
.setMethodDescriptor(echoShouldIncludeMethodDescriptor) | ||
.build(); | ||
GrpcCallSettings<EchoRequest, EchoResponse> chatShouldIncludeTransportSettings = | ||
GrpcCallSettings.<EchoRequest, EchoResponse>newBuilder() | ||
.setMethodDescriptor(chatShouldIncludeMethodDescriptor) | ||
.build(); | ||
GrpcCallSettings<EchoRequest, EchoResponse> chatAgainShouldIncludeTransportSettings = | ||
GrpcCallSettings.<EchoRequest, EchoResponse>newBuilder() | ||
.setMethodDescriptor(chatAgainShouldIncludeMethodDescriptor) | ||
.build(); | ||
|
||
this.echoShouldIncludeCallable = | ||
callableFactory.createUnaryCallable( | ||
echoShouldIncludeTransportSettings, | ||
settings.echoShouldIncludeSettings(), | ||
clientContext); | ||
this.chatShouldIncludeCallable = | ||
callableFactory.createBidiStreamingCallable( | ||
chatShouldIncludeTransportSettings, | ||
settings.chatShouldIncludeSettings(), | ||
clientContext); | ||
this.chatAgainShouldIncludeCallable = | ||
callableFactory.createBidiStreamingCallable( | ||
chatAgainShouldIncludeTransportSettings, | ||
settings.chatAgainShouldIncludeSettings(), | ||
clientContext); | ||
|
||
this.backgroundResources = | ||
new BackgroundResourceAggregation(clientContext.getBackgroundResources()); | ||
} | ||
|
||
public GrpcOperationsStub getOperationsStub() { | ||
return operationsStub; | ||
} | ||
|
||
@Override | ||
public UnaryCallable<EchoRequest, EchoResponse> echoShouldIncludeCallable() { | ||
return echoShouldIncludeCallable; | ||
} | ||
|
||
@Override | ||
public BidiStreamingCallable<EchoRequest, EchoResponse> chatShouldIncludeCallable() { | ||
return chatShouldIncludeCallable; | ||
} | ||
|
||
@Override | ||
public BidiStreamingCallable<EchoRequest, EchoResponse> chatAgainShouldIncludeCallable() { | ||
return chatAgainShouldIncludeCallable; | ||
} | ||
|
||
@Override | ||
public final void close() { | ||
try { | ||
backgroundResources.close(); | ||
} catch (RuntimeException e) { | ||
throw e; | ||
} catch (Exception e) { | ||
throw new IllegalStateException("Failed to close resource", e); | ||
} | ||
} | ||
|
||
@Override | ||
public void shutdown() { | ||
backgroundResources.shutdown(); | ||
} | ||
|
||
@Override | ||
public boolean isShutdown() { | ||
return backgroundResources.isShutdown(); | ||
} | ||
|
||
@Override | ||
public boolean isTerminated() { | ||
return backgroundResources.isTerminated(); | ||
} | ||
|
||
@Override | ||
public void shutdownNow() { | ||
backgroundResources.shutdownNow(); | ||
} | ||
|
||
@Override | ||
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { | ||
return backgroundResources.awaitTermination(duration, unit); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.