@Generated(value="by gapic-generator-java") public class CursorServiceClient extends Object implements com.google.api.gax.core.BackgroundResource
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:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CursorServiceClient cursorServiceClient = CursorServiceClient.create()) {
CommitCursorRequest request =
CommitCursorRequest.newBuilder()
.setSubscription("subscription341203229")
.setPartition(-1799810326)
.setCursor(Cursor.newBuilder().build())
.build();
CommitCursorResponse response = cursorServiceClient.commitCursor(request);
}
Note: close() needs to be called on the CursorServiceClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
The surface of this class includes several types of Java methods for each of the API's methods:
See the individual methods for example code.
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.
This class can be customized by passing in a custom instance of CursorServiceSettings to create(). For example:
To customize credentials:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
CursorServiceSettings cursorServiceSettings =
CursorServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
CursorServiceClient cursorServiceClient = CursorServiceClient.create(cursorServiceSettings);
To customize the endpoint:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
CursorServiceSettings cursorServiceSettings =
CursorServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
CursorServiceClient cursorServiceClient = CursorServiceClient.create(cursorServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
| Modifier and Type | Class and Description |
|---|---|
static class |
CursorServiceClient.ListPartitionCursorsFixedSizeCollection |
static class |
CursorServiceClient.ListPartitionCursorsPage |
static class |
CursorServiceClient.ListPartitionCursorsPagedResponse |
| Modifier | Constructor and Description |
|---|---|
protected |
CursorServiceClient(CursorServiceSettings settings)
Constructs an instance of CursorServiceClient, using the given settings.
|
protected |
CursorServiceClient(CursorServiceStub stub) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
CommitCursorResponse |
commitCursor(CommitCursorRequest request)
Updates the committed cursor.
|
com.google.api.gax.rpc.UnaryCallable<CommitCursorRequest,CommitCursorResponse> |
commitCursorCallable()
Updates the committed cursor.
|
static CursorServiceClient |
create()
Constructs an instance of CursorServiceClient with default settings.
|
static CursorServiceClient |
create(CursorServiceSettings settings)
Constructs an instance of CursorServiceClient, using the given settings.
|
static CursorServiceClient |
create(CursorServiceStub stub)
Constructs an instance of CursorServiceClient, using the given stub for making calls.
|
CursorServiceSettings |
getSettings() |
CursorServiceStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
CursorServiceClient.ListPartitionCursorsPagedResponse |
listPartitionCursors(ListPartitionCursorsRequest request)
Returns all committed cursor information for a subscription.
|
CursorServiceClient.ListPartitionCursorsPagedResponse |
listPartitionCursors(String parent)
Returns all committed cursor information for a subscription.
|
CursorServiceClient.ListPartitionCursorsPagedResponse |
listPartitionCursors(SubscriptionName parent)
Returns all committed cursor information for a subscription.
|
com.google.api.gax.rpc.UnaryCallable<ListPartitionCursorsRequest,ListPartitionCursorsResponse> |
listPartitionCursorsCallable()
Returns all committed cursor information for a subscription.
|
com.google.api.gax.rpc.UnaryCallable<ListPartitionCursorsRequest,CursorServiceClient.ListPartitionCursorsPagedResponse> |
listPartitionCursorsPagedCallable()
Returns all committed cursor information for a subscription.
|
void |
shutdown() |
void |
shutdownNow() |
com.google.api.gax.rpc.BidiStreamingCallable<StreamingCommitCursorRequest,StreamingCommitCursorResponse> |
streamingCommitCursorCallable()
Establishes a stream with the server for managing committed cursors.
|
protected CursorServiceClient(CursorServiceSettings settings) throws IOException
IOExceptionprotected CursorServiceClient(CursorServiceStub stub)
public static final CursorServiceClient create() throws IOException
IOExceptionpublic static final CursorServiceClient create(CursorServiceSettings settings) throws IOException
IOExceptionpublic static final CursorServiceClient create(CursorServiceStub stub)
public final CursorServiceSettings getSettings()
public CursorServiceStub getStub()
public final com.google.api.gax.rpc.BidiStreamingCallable<StreamingCommitCursorRequest,StreamingCommitCursorResponse> streamingCommitCursorCallable()
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CursorServiceClient cursorServiceClient = CursorServiceClient.create()) {
BidiStream<StreamingCommitCursorRequest, StreamingCommitCursorResponse> bidiStream =
cursorServiceClient.streamingCommitCursorCallable().call();
StreamingCommitCursorRequest request = StreamingCommitCursorRequest.newBuilder().build();
bidiStream.send(request);
for (StreamingCommitCursorResponse response : bidiStream) {
// Do something when a response is received.
}
}
public final CommitCursorResponse commitCursor(CommitCursorRequest request)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CursorServiceClient cursorServiceClient = CursorServiceClient.create()) {
CommitCursorRequest request =
CommitCursorRequest.newBuilder()
.setSubscription("subscription341203229")
.setPartition(-1799810326)
.setCursor(Cursor.newBuilder().build())
.build();
CommitCursorResponse response = cursorServiceClient.commitCursor(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<CommitCursorRequest,CommitCursorResponse> commitCursorCallable()
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CursorServiceClient cursorServiceClient = CursorServiceClient.create()) {
CommitCursorRequest request =
CommitCursorRequest.newBuilder()
.setSubscription("subscription341203229")
.setPartition(-1799810326)
.setCursor(Cursor.newBuilder().build())
.build();
ApiFuture<CommitCursorResponse> future =
cursorServiceClient.commitCursorCallable().futureCall(request);
// Do something.
CommitCursorResponse response = future.get();
}
public final CursorServiceClient.ListPartitionCursorsPagedResponse listPartitionCursors(SubscriptionName parent)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CursorServiceClient cursorServiceClient = CursorServiceClient.create()) {
SubscriptionName parent = SubscriptionName.of("[PROJECT]", "[LOCATION]", "[SUBSCRIPTION]");
for (PartitionCursor element :
cursorServiceClient.listPartitionCursors(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. The subscription for which to retrieve cursors. Structured like
`projects/{project_number}/locations/{location}/subscriptions/{subscription_id}`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final CursorServiceClient.ListPartitionCursorsPagedResponse listPartitionCursors(String parent)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CursorServiceClient cursorServiceClient = CursorServiceClient.create()) {
String parent = SubscriptionName.of("[PROJECT]", "[LOCATION]", "[SUBSCRIPTION]").toString();
for (PartitionCursor element :
cursorServiceClient.listPartitionCursors(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. The subscription for which to retrieve cursors. Structured like
`projects/{project_number}/locations/{location}/subscriptions/{subscription_id}`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final CursorServiceClient.ListPartitionCursorsPagedResponse listPartitionCursors(ListPartitionCursorsRequest request)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CursorServiceClient cursorServiceClient = CursorServiceClient.create()) {
ListPartitionCursorsRequest request =
ListPartitionCursorsRequest.newBuilder()
.setParent(
SubscriptionName.of("[PROJECT]", "[LOCATION]", "[SUBSCRIPTION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (PartitionCursor element :
cursorServiceClient.listPartitionCursors(request).iterateAll()) {
// doThingsWith(element);
}
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<ListPartitionCursorsRequest,CursorServiceClient.ListPartitionCursorsPagedResponse> listPartitionCursorsPagedCallable()
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CursorServiceClient cursorServiceClient = CursorServiceClient.create()) {
ListPartitionCursorsRequest request =
ListPartitionCursorsRequest.newBuilder()
.setParent(
SubscriptionName.of("[PROJECT]", "[LOCATION]", "[SUBSCRIPTION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<PartitionCursor> future =
cursorServiceClient.listPartitionCursorsPagedCallable().futureCall(request);
// Do something.
for (PartitionCursor element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<ListPartitionCursorsRequest,ListPartitionCursorsResponse> listPartitionCursorsCallable()
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (CursorServiceClient cursorServiceClient = CursorServiceClient.create()) {
ListPartitionCursorsRequest request =
ListPartitionCursorsRequest.newBuilder()
.setParent(
SubscriptionName.of("[PROJECT]", "[LOCATION]", "[SUBSCRIPTION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListPartitionCursorsResponse response =
cursorServiceClient.listPartitionCursorsCallable().call(request);
for (PartitionCursor element : response.getPartitionCursorsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final void close()
close in interface AutoCloseablepublic void shutdown()
shutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isShutdown()
isShutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isTerminated()
isTerminated in interface com.google.api.gax.core.BackgroundResourcepublic void shutdownNow()
shutdownNow in interface com.google.api.gax.core.BackgroundResourcepublic boolean awaitTermination(long duration,
TimeUnit unit)
throws InterruptedException
awaitTermination in interface com.google.api.gax.core.BackgroundResourceInterruptedExceptionCopyright © 2022 Google LLC. All rights reserved.