Skip to content

Commit

Permalink
feat: Add autoscaling config in the instance to support autoscaling i…
Browse files Browse the repository at this point in the history
…n 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 <[email protected]>
  • Loading branch information
3 people authored Dec 15, 2023
1 parent e62b4fe commit 99ae565
Show file tree
Hide file tree
Showing 161 changed files with 135,312 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ If you are using Maven without the BOM, add this to your dependencies:
If you are using Gradle 5.x or later, add this to your dependencies:

```Groovy
implementation platform('com.google.cloud:libraries-bom:26.28.0')
implementation platform('com.google.cloud:libraries-bom:26.29.0')
implementation 'com.google.cloud:google-cloud-spanner'
```
Expand Down
37 changes: 37 additions & 0 deletions google-cloud-spanner-executor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
<groupId>io.grpc</groupId>
<artifactId>grpc-netty-shaded</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
Expand Down Expand Up @@ -129,6 +133,28 @@
<artifactId>commons-io</artifactId>
<version>2.15.1</version>
</dependency>

<!-- Test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>

<!-- Need testing utility classes for generated gRPC clients tests -->
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax</artifactId>
<classifier>testlib</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax-grpc</artifactId>
<classifier>testlib</classifier>
<scope>test</scope>
</dependency>

</dependencies>
<build>
<finalName>google-spanner-cloud-executor</finalName>
Expand Down Expand Up @@ -162,5 +188,16 @@
<version>3.1.2</version>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<ignoredDependencies> com.google.api:gax</ignoredDependencies>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
/*
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.google.cloud.spanner.executor.v1;

import com.google.api.gax.core.BackgroundResource;
import com.google.api.gax.rpc.BidiStreamingCallable;
import com.google.cloud.spanner.executor.v1.stub.SpannerExecutorProxyStub;
import com.google.cloud.spanner.executor.v1.stub.SpannerExecutorProxyStubSettings;
import com.google.spanner.executor.v1.SpannerAsyncActionRequest;
import com.google.spanner.executor.v1.SpannerAsyncActionResponse;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import javax.annotation.Generated;

// AUTO-GENERATED DOCUMENTATION AND CLASS.
/**
* Service Description: Service that executes SpannerActions asynchronously.
*
* <p>This class provides the ability to make remote calls to the backing service through method
* calls that map to API methods. Sample code to get started:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (SpannerExecutorProxyClient spannerExecutorProxyClient =
* SpannerExecutorProxyClient.create()) {
* BidiStream<SpannerAsyncActionRequest, SpannerAsyncActionResponse> bidiStream =
* spannerExecutorProxyClient.executeActionAsyncCallable().call();
* SpannerAsyncActionRequest request =
* SpannerAsyncActionRequest.newBuilder()
* .setActionId(198295492)
* .setAction(SpannerAction.newBuilder().build())
* .build();
* bidiStream.send(request);
* for (SpannerAsyncActionResponse response : bidiStream) {
* // Do something when a response is received.
* }
* }
* }</pre>
*
* <p>Note: close() needs to be called on the SpannerExecutorProxyClient object to clean up
* resources such as threads. In the example above, try-with-resources is used, which automatically
* calls close().
*
* <p>The surface of this class includes several types of Java methods for each of the API's
* methods:
*
* <ol>
* <li>A "flattened" method. With this type of method, the fields of the request type have been
* converted into function parameters. It may be the case that not all fields are available as
* parameters, and not every API method will have a flattened method entry point.
* <li>A "request object" method. This type of method only takes one parameter, a request object,
* which must be constructed before the call. Not every API method will have a request object
* method.
* <li>A "callable" method. This type of method takes no parameters and returns an immutable API
* callable object, which can be used to initiate calls to the service.
* </ol>
*
* <p>See the individual methods for example code.
*
* <p>Many parameters require resource names to be formatted in a particular way. To assist with
* these names, this class includes a format method for each type of name, and additionally a parse
* method to extract the individual identifiers contained within names that are returned.
*
* <p>This class can be customized by passing in a custom instance of SpannerExecutorProxySettings
* to create(). For example:
*
* <p>To customize credentials:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* SpannerExecutorProxySettings spannerExecutorProxySettings =
* SpannerExecutorProxySettings.newBuilder()
* .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
* .build();
* SpannerExecutorProxyClient spannerExecutorProxyClient =
* SpannerExecutorProxyClient.create(spannerExecutorProxySettings);
* }</pre>
*
* <p>To customize the endpoint:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* SpannerExecutorProxySettings spannerExecutorProxySettings =
* SpannerExecutorProxySettings.newBuilder().setEndpoint(myEndpoint).build();
* SpannerExecutorProxyClient spannerExecutorProxyClient =
* SpannerExecutorProxyClient.create(spannerExecutorProxySettings);
* }</pre>
*
* <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
*/
@Generated("by gapic-generator-java")
public class SpannerExecutorProxyClient implements BackgroundResource {
private final SpannerExecutorProxySettings settings;
private final SpannerExecutorProxyStub stub;

/** Constructs an instance of SpannerExecutorProxyClient with default settings. */
public static final SpannerExecutorProxyClient create() throws IOException {
return create(SpannerExecutorProxySettings.newBuilder().build());
}

/**
* Constructs an instance of SpannerExecutorProxyClient, using the given settings. The channels
* are created based on the settings passed in, or defaults for any settings that are not set.
*/
public static final SpannerExecutorProxyClient create(SpannerExecutorProxySettings settings)
throws IOException {
return new SpannerExecutorProxyClient(settings);
}

/**
* Constructs an instance of SpannerExecutorProxyClient, using the given stub for making calls.
* This is for advanced usage - prefer using create(SpannerExecutorProxySettings).
*/
public static final SpannerExecutorProxyClient create(SpannerExecutorProxyStub stub) {
return new SpannerExecutorProxyClient(stub);
}

/**
* Constructs an instance of SpannerExecutorProxyClient, 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 SpannerExecutorProxyClient(SpannerExecutorProxySettings settings) throws IOException {
this.settings = settings;
this.stub = ((SpannerExecutorProxyStubSettings) settings.getStubSettings()).createStub();
}

protected SpannerExecutorProxyClient(SpannerExecutorProxyStub stub) {
this.settings = null;
this.stub = stub;
}

public final SpannerExecutorProxySettings getSettings() {
return settings;
}

public SpannerExecutorProxyStub getStub() {
return stub;
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* ExecuteActionAsync is a streaming call that starts executing a new Spanner action.
*
* <p>For each request, the server will reply with one or more responses, but only the last
* response will contain status in the outcome.
*
* <p>Responses can be matched to requests by action_id. It is allowed to have multiple actions in
* flight--in that case, actions are be executed in parallel.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (SpannerExecutorProxyClient spannerExecutorProxyClient =
* SpannerExecutorProxyClient.create()) {
* BidiStream<SpannerAsyncActionRequest, SpannerAsyncActionResponse> bidiStream =
* spannerExecutorProxyClient.executeActionAsyncCallable().call();
* SpannerAsyncActionRequest request =
* SpannerAsyncActionRequest.newBuilder()
* .setActionId(198295492)
* .setAction(SpannerAction.newBuilder().build())
* .build();
* bidiStream.send(request);
* for (SpannerAsyncActionResponse response : bidiStream) {
* // Do something when a response is received.
* }
* }
* }</pre>
*/
public final BidiStreamingCallable<SpannerAsyncActionRequest, SpannerAsyncActionResponse>
executeActionAsyncCallable() {
return stub.executeActionAsyncCallable();
}

@Override
public final void close() {
stub.close();
}

@Override
public void shutdown() {
stub.shutdown();
}

@Override
public boolean isShutdown() {
return stub.isShutdown();
}

@Override
public boolean isTerminated() {
return stub.isTerminated();
}

@Override
public void shutdownNow() {
stub.shutdownNow();
}

@Override
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
return stub.awaitTermination(duration, unit);
}
}
Loading

0 comments on commit 99ae565

Please sign in to comment.