Skip to content

Commit 99ae565

Browse files
feat: Add autoscaling config in the instance to support autoscaling in systests (#2756)
* chore: Update package name for gapic generated executor code PiperOrigin-RevId: 589051885 Source-Link: googleapis/googleapis@90936c4 Source-Link: https://github.com/googleapis/googleapis-gen/commit/0b083b8384bd0ba7c8fe26320080d7a6c49af3ae Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMGIwODNiODM4NGJkMGJhN2M4ZmUyNjMyMDA4MGQ3YTZjNDlhZjNhZSJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * feat: Add autoscaling config in the instance to support autoscaling in systests PiperOrigin-RevId: 589163292 Source-Link: googleapis/googleapis@03d2cc1 Source-Link: https://github.com/googleapis/googleapis-gen/commit/3a0a047f6d6fc88ee17cd71f9bf8e31802daf4f6 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiM2EwYTA0N2Y2ZDZmYzg4ZWUxN2NkNzFmOWJmOGUzMTgwMmRhZjRmNiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * fix: update pom.xml files to fix failing builds * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * fix: version in pom.xml * fix: add test dependencies * fix: update clirr * fix: ignore dependencies * fix: update pom.xml files to ignore dependencies --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Sri Harsha CH <57220027+harshachinta@users.noreply.github.com>
1 parent e62b4fe commit 99ae565

File tree

161 files changed

+135312
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

161 files changed

+135312
-2
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ If you are using Maven without the BOM, add this to your dependencies:
5050
If you are using Gradle 5.x or later, add this to your dependencies:
5151

5252
```Groovy
53-
implementation platform('com.google.cloud:libraries-bom:26.28.0')
53+
implementation platform('com.google.cloud:libraries-bom:26.29.0')
5454
5555
implementation 'com.google.cloud:google-cloud-spanner'
5656
```

google-cloud-spanner-executor/pom.xml

+37
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
<groupId>io.grpc</groupId>
3535
<artifactId>grpc-netty-shaded</artifactId>
3636
</dependency>
37+
<dependency>
38+
<groupId>io.grpc</groupId>
39+
<artifactId>grpc-protobuf</artifactId>
40+
</dependency>
3741
<dependency>
3842
<groupId>io.grpc</groupId>
3943
<artifactId>grpc-stub</artifactId>
@@ -129,6 +133,28 @@
129133
<artifactId>commons-io</artifactId>
130134
<version>2.15.1</version>
131135
</dependency>
136+
137+
<!-- Test dependencies -->
138+
<dependency>
139+
<groupId>junit</groupId>
140+
<artifactId>junit</artifactId>
141+
<scope>test</scope>
142+
</dependency>
143+
144+
<!-- Need testing utility classes for generated gRPC clients tests -->
145+
<dependency>
146+
<groupId>com.google.api</groupId>
147+
<artifactId>gax</artifactId>
148+
<classifier>testlib</classifier>
149+
<scope>test</scope>
150+
</dependency>
151+
<dependency>
152+
<groupId>com.google.api</groupId>
153+
<artifactId>gax-grpc</artifactId>
154+
<classifier>testlib</classifier>
155+
<scope>test</scope>
156+
</dependency>
157+
132158
</dependencies>
133159
<build>
134160
<finalName>google-spanner-cloud-executor</finalName>
@@ -162,5 +188,16 @@
162188
<version>3.1.2</version>
163189
</plugin>
164190
</plugins>
191+
<pluginManagement>
192+
<plugins>
193+
<plugin>
194+
<groupId>org.apache.maven.plugins</groupId>
195+
<artifactId>maven-dependency-plugin</artifactId>
196+
<configuration>
197+
<ignoredDependencies> com.google.api:gax</ignoredDependencies>
198+
</configuration>
199+
</plugin>
200+
</plugins>
201+
</pluginManagement>
165202
</build>
166203
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,235 @@
1+
/*
2+
* Copyright 2023 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.cloud.spanner.executor.v1;
18+
19+
import com.google.api.gax.core.BackgroundResource;
20+
import com.google.api.gax.rpc.BidiStreamingCallable;
21+
import com.google.cloud.spanner.executor.v1.stub.SpannerExecutorProxyStub;
22+
import com.google.cloud.spanner.executor.v1.stub.SpannerExecutorProxyStubSettings;
23+
import com.google.spanner.executor.v1.SpannerAsyncActionRequest;
24+
import com.google.spanner.executor.v1.SpannerAsyncActionResponse;
25+
import java.io.IOException;
26+
import java.util.concurrent.TimeUnit;
27+
import javax.annotation.Generated;
28+
29+
// AUTO-GENERATED DOCUMENTATION AND CLASS.
30+
/**
31+
* Service Description: Service that executes SpannerActions asynchronously.
32+
*
33+
* <p>This class provides the ability to make remote calls to the backing service through method
34+
* calls that map to API methods. Sample code to get started:
35+
*
36+
* <pre>{@code
37+
* // This snippet has been automatically generated and should be regarded as a code template only.
38+
* // It will require modifications to work:
39+
* // - It may require correct/in-range values for request initialization.
40+
* // - It may require specifying regional endpoints when creating the service client as shown in
41+
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
42+
* try (SpannerExecutorProxyClient spannerExecutorProxyClient =
43+
* SpannerExecutorProxyClient.create()) {
44+
* BidiStream<SpannerAsyncActionRequest, SpannerAsyncActionResponse> bidiStream =
45+
* spannerExecutorProxyClient.executeActionAsyncCallable().call();
46+
* SpannerAsyncActionRequest request =
47+
* SpannerAsyncActionRequest.newBuilder()
48+
* .setActionId(198295492)
49+
* .setAction(SpannerAction.newBuilder().build())
50+
* .build();
51+
* bidiStream.send(request);
52+
* for (SpannerAsyncActionResponse response : bidiStream) {
53+
* // Do something when a response is received.
54+
* }
55+
* }
56+
* }</pre>
57+
*
58+
* <p>Note: close() needs to be called on the SpannerExecutorProxyClient object to clean up
59+
* resources such as threads. In the example above, try-with-resources is used, which automatically
60+
* calls close().
61+
*
62+
* <p>The surface of this class includes several types of Java methods for each of the API's
63+
* methods:
64+
*
65+
* <ol>
66+
* <li>A "flattened" method. With this type of method, the fields of the request type have been
67+
* converted into function parameters. It may be the case that not all fields are available as
68+
* parameters, and not every API method will have a flattened method entry point.
69+
* <li>A "request object" method. This type of method only takes one parameter, a request object,
70+
* which must be constructed before the call. Not every API method will have a request object
71+
* method.
72+
* <li>A "callable" method. This type of method takes no parameters and returns an immutable API
73+
* callable object, which can be used to initiate calls to the service.
74+
* </ol>
75+
*
76+
* <p>See the individual methods for example code.
77+
*
78+
* <p>Many parameters require resource names to be formatted in a particular way. To assist with
79+
* these names, this class includes a format method for each type of name, and additionally a parse
80+
* method to extract the individual identifiers contained within names that are returned.
81+
*
82+
* <p>This class can be customized by passing in a custom instance of SpannerExecutorProxySettings
83+
* to create(). For example:
84+
*
85+
* <p>To customize credentials:
86+
*
87+
* <pre>{@code
88+
* // This snippet has been automatically generated and should be regarded as a code template only.
89+
* // It will require modifications to work:
90+
* // - It may require correct/in-range values for request initialization.
91+
* // - It may require specifying regional endpoints when creating the service client as shown in
92+
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
93+
* SpannerExecutorProxySettings spannerExecutorProxySettings =
94+
* SpannerExecutorProxySettings.newBuilder()
95+
* .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
96+
* .build();
97+
* SpannerExecutorProxyClient spannerExecutorProxyClient =
98+
* SpannerExecutorProxyClient.create(spannerExecutorProxySettings);
99+
* }</pre>
100+
*
101+
* <p>To customize the endpoint:
102+
*
103+
* <pre>{@code
104+
* // This snippet has been automatically generated and should be regarded as a code template only.
105+
* // It will require modifications to work:
106+
* // - It may require correct/in-range values for request initialization.
107+
* // - It may require specifying regional endpoints when creating the service client as shown in
108+
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
109+
* SpannerExecutorProxySettings spannerExecutorProxySettings =
110+
* SpannerExecutorProxySettings.newBuilder().setEndpoint(myEndpoint).build();
111+
* SpannerExecutorProxyClient spannerExecutorProxyClient =
112+
* SpannerExecutorProxyClient.create(spannerExecutorProxySettings);
113+
* }</pre>
114+
*
115+
* <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
116+
*/
117+
@Generated("by gapic-generator-java")
118+
public class SpannerExecutorProxyClient implements BackgroundResource {
119+
private final SpannerExecutorProxySettings settings;
120+
private final SpannerExecutorProxyStub stub;
121+
122+
/** Constructs an instance of SpannerExecutorProxyClient with default settings. */
123+
public static final SpannerExecutorProxyClient create() throws IOException {
124+
return create(SpannerExecutorProxySettings.newBuilder().build());
125+
}
126+
127+
/**
128+
* Constructs an instance of SpannerExecutorProxyClient, using the given settings. The channels
129+
* are created based on the settings passed in, or defaults for any settings that are not set.
130+
*/
131+
public static final SpannerExecutorProxyClient create(SpannerExecutorProxySettings settings)
132+
throws IOException {
133+
return new SpannerExecutorProxyClient(settings);
134+
}
135+
136+
/**
137+
* Constructs an instance of SpannerExecutorProxyClient, using the given stub for making calls.
138+
* This is for advanced usage - prefer using create(SpannerExecutorProxySettings).
139+
*/
140+
public static final SpannerExecutorProxyClient create(SpannerExecutorProxyStub stub) {
141+
return new SpannerExecutorProxyClient(stub);
142+
}
143+
144+
/**
145+
* Constructs an instance of SpannerExecutorProxyClient, using the given settings. This is
146+
* protected so that it is easy to make a subclass, but otherwise, the static factory methods
147+
* should be preferred.
148+
*/
149+
protected SpannerExecutorProxyClient(SpannerExecutorProxySettings settings) throws IOException {
150+
this.settings = settings;
151+
this.stub = ((SpannerExecutorProxyStubSettings) settings.getStubSettings()).createStub();
152+
}
153+
154+
protected SpannerExecutorProxyClient(SpannerExecutorProxyStub stub) {
155+
this.settings = null;
156+
this.stub = stub;
157+
}
158+
159+
public final SpannerExecutorProxySettings getSettings() {
160+
return settings;
161+
}
162+
163+
public SpannerExecutorProxyStub getStub() {
164+
return stub;
165+
}
166+
167+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
168+
/**
169+
* ExecuteActionAsync is a streaming call that starts executing a new Spanner action.
170+
*
171+
* <p>For each request, the server will reply with one or more responses, but only the last
172+
* response will contain status in the outcome.
173+
*
174+
* <p>Responses can be matched to requests by action_id. It is allowed to have multiple actions in
175+
* flight--in that case, actions are be executed in parallel.
176+
*
177+
* <p>Sample code:
178+
*
179+
* <pre>{@code
180+
* // This snippet has been automatically generated and should be regarded as a code template only.
181+
* // It will require modifications to work:
182+
* // - It may require correct/in-range values for request initialization.
183+
* // - It may require specifying regional endpoints when creating the service client as shown in
184+
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
185+
* try (SpannerExecutorProxyClient spannerExecutorProxyClient =
186+
* SpannerExecutorProxyClient.create()) {
187+
* BidiStream<SpannerAsyncActionRequest, SpannerAsyncActionResponse> bidiStream =
188+
* spannerExecutorProxyClient.executeActionAsyncCallable().call();
189+
* SpannerAsyncActionRequest request =
190+
* SpannerAsyncActionRequest.newBuilder()
191+
* .setActionId(198295492)
192+
* .setAction(SpannerAction.newBuilder().build())
193+
* .build();
194+
* bidiStream.send(request);
195+
* for (SpannerAsyncActionResponse response : bidiStream) {
196+
* // Do something when a response is received.
197+
* }
198+
* }
199+
* }</pre>
200+
*/
201+
public final BidiStreamingCallable<SpannerAsyncActionRequest, SpannerAsyncActionResponse>
202+
executeActionAsyncCallable() {
203+
return stub.executeActionAsyncCallable();
204+
}
205+
206+
@Override
207+
public final void close() {
208+
stub.close();
209+
}
210+
211+
@Override
212+
public void shutdown() {
213+
stub.shutdown();
214+
}
215+
216+
@Override
217+
public boolean isShutdown() {
218+
return stub.isShutdown();
219+
}
220+
221+
@Override
222+
public boolean isTerminated() {
223+
return stub.isTerminated();
224+
}
225+
226+
@Override
227+
public void shutdownNow() {
228+
stub.shutdownNow();
229+
}
230+
231+
@Override
232+
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
233+
return stub.awaitTermination(duration, unit);
234+
}
235+
}

0 commit comments

Comments
 (0)