@Generated(value="by gapic-generator") @BetaApi 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:
try (CursorServiceClient cursorServiceClient = CursorServiceClient.create()) {
SubscriptionName parent = SubscriptionName.of("[PROJECT]", "[LOCATION]", "[SUBSCRIPTION]");
for (PartitionCursor element : cursorServiceClient.listPartitionCursors(parent).iterateAll()) {
// doThingsWith(element);
}
}
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:
CursorServiceSettings cursorServiceSettings =
CursorServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
CursorServiceClient cursorServiceClient =
CursorServiceClient.create(cursorServiceSettings);
To customize the endpoint:
CursorServiceSettings cursorServiceSettings =
CursorServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
CursorServiceClient cursorServiceClient =
CursorServiceClient.create(cursorServiceSettings);
| 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
IOException@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected CursorServiceClient(CursorServiceStub stub)
public static final CursorServiceClient create() throws IOException
IOExceptionpublic static final CursorServiceClient create(CursorServiceSettings settings) throws IOException
IOException@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final CursorServiceClient create(CursorServiceStub stub)
public final CursorServiceSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public CursorServiceStub getStub()
public final com.google.api.gax.rpc.BidiStreamingCallable<StreamingCommitCursorRequest,StreamingCommitCursorResponse> streamingCommitCursorCallable()
Sample code:
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 receive a response
}
}
public final CommitCursorResponse commitCursor(CommitCursorRequest request)
Sample code:
try (CursorServiceClient cursorServiceClient = CursorServiceClient.create()) {
CommitCursorRequest request = CommitCursorRequest.newBuilder().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:
try (CursorServiceClient cursorServiceClient = CursorServiceClient.create()) {
CommitCursorRequest request = CommitCursorRequest.newBuilder().build();
ApiFuture<CommitCursorResponse> future = cursorServiceClient.commitCursorCallable().futureCall(request);
// Do something
CommitCursorResponse response = future.get();
}
public final CursorServiceClient.ListPartitionCursorsPagedResponse listPartitionCursors(SubscriptionName parent)
Sample code:
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:
try (CursorServiceClient cursorServiceClient = CursorServiceClient.create()) {
SubscriptionName parent = SubscriptionName.of("[PROJECT]", "[LOCATION]", "[SUBSCRIPTION]");
for (PartitionCursor element : cursorServiceClient.listPartitionCursors(parent.toString()).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:
try (CursorServiceClient cursorServiceClient = CursorServiceClient.create()) {
SubscriptionName parent = SubscriptionName.of("[PROJECT]", "[LOCATION]", "[SUBSCRIPTION]");
ListPartitionCursorsRequest request = ListPartitionCursorsRequest.newBuilder()
.setParent(parent.toString())
.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:
try (CursorServiceClient cursorServiceClient = CursorServiceClient.create()) {
SubscriptionName parent = SubscriptionName.of("[PROJECT]", "[LOCATION]", "[SUBSCRIPTION]");
ListPartitionCursorsRequest request = ListPartitionCursorsRequest.newBuilder()
.setParent(parent.toString())
.build();
ApiFuture<ListPartitionCursorsPagedResponse> 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:
try (CursorServiceClient cursorServiceClient = CursorServiceClient.create()) {
SubscriptionName parent = SubscriptionName.of("[PROJECT]", "[LOCATION]", "[SUBSCRIPTION]");
ListPartitionCursorsRequest request = ListPartitionCursorsRequest.newBuilder()
.setParent(parent.toString())
.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 © 2020 Google LLC. All rights reserved.