public class SpannerDatabaseTailer extends com.google.api.core.AbstractApiService implements SpannerDatabaseChangeWatcher
SpannerDatabaseChangeWatcher interface that continuously polls a
set of tables for changes based on commit timestamp columns in the tables.
Example usage for watching all tables in a database:
{@code
String instance = "my-instance";
String database = "my-database";
Spanner spanner = SpannerOptions.getDefaultInstance().getService();
DatabaseId databaseId = DatabaseId.of(SpannerOptions.getDefaultProjectId(), instance, database);
SpannerDatabaseChangeWatcher watcher =
SpannerDatabaseTailer.newBuilder(spanner, databaseId).allTables().build();
watcher.addCallback(
new RowChangeCallback() {| Modifier and Type | Class and Description |
|---|---|
static interface |
SpannerDatabaseTailer.Builder
Builder for a
SpannerDatabaseTailer. |
static interface |
SpannerDatabaseTailer.TableExcluder
Interface for excluding specific tables from a
SpannerDatabaseTailer. |
static interface |
SpannerDatabaseTailer.TableSelecter
Interface for selecting the tables that should be monitored by a
SpannerDatabaseTailer. |
| Modifier and Type | Method and Description |
|---|---|
void |
addCallback(SpannerTableChangeWatcher.RowChangeCallback callback)
Adds a
SpannerTableChangeWatcher.RowChangeCallback for this SpannerDatabaseChangeWatcher. |
protected void |
doStart() |
protected void |
doStop() |
com.google.cloud.spanner.DatabaseId |
getDatabaseId()
Returns the id of the database that is being monitored for changes.
|
List<TableId> |
getTables()
Returns the ids of the tables that are monitored by this watcher.
|
static SpannerDatabaseTailer.TableSelecter |
newBuilder(com.google.cloud.spanner.Spanner spanner,
com.google.cloud.spanner.DatabaseId databaseId)
Creates a builder for a
SpannerDatabaseTailer. |
addListener, awaitRunning, awaitRunning, awaitTerminated, awaitTerminated, failureCause, isRunning, notifyFailed, notifyStarted, notifyStopped, startAsync, state, stopAsyncpublic static SpannerDatabaseTailer.TableSelecter newBuilder(com.google.cloud.spanner.Spanner spanner, com.google.cloud.spanner.DatabaseId databaseId)
SpannerDatabaseTailer.public void addCallback(SpannerTableChangeWatcher.RowChangeCallback callback)
SpannerDatabaseChangeWatcherSpannerTableChangeWatcher.RowChangeCallback for this SpannerDatabaseChangeWatcher. Callbacks may
only be added when the ApiService.state() of this SpannerDatabaseChangeWatcher is ApiService.State.NEW. Callbacks for one table will always be in order of commit timestamp, and only one
callback will be active at any time for a table. Callbacks for different tables may be called
in parallel, and there is no guarantee to the ordering of callbacks over multiple tables.addCallback in interface SpannerDatabaseChangeWatcherprotected void doStart()
doStart in class com.google.api.core.AbstractApiServiceprotected void doStop()
doStop in class com.google.api.core.AbstractApiServicepublic com.google.cloud.spanner.DatabaseId getDatabaseId()
SpannerDatabaseChangeWatchergetDatabaseId in interface SpannerDatabaseChangeWatcherpublic List<TableId> getTables()
SpannerDatabaseChangeWatcherSpannerDatabaseChangeWatcher to make a round-trip to the database to determine the
actual tables that are being monitored.getTables in interface SpannerDatabaseChangeWatcherCopyright © 2022 Google LLC. All rights reserved.