Class FixedShardProvider

  • All Implemented Interfaces:
    ShardProvider

    public final class FixedShardProvider
    extends Object
    implements ShardProvider
    Implementation of ShardProvider that returns a fixed shard id. This can be used in combination with multiple change watchers, where each change watcher is responsible for watching a specific segment of the table.

    Example usage in combination with a SpannerTableTailer:

    
     String shards = new String[] {"EAST", "WEST"};
     for (String shard : shards) {
       SpannerTableTailer tailer =
           SpannerTableTailer.newBuilder(
                   spanner, TableId.of(databaseId, "TABLE_NAME"))
               .setShardProvider(FixedShardProvider.create("SHARD_COLUMN", shard))
               .build();
     }