Implement ConnectionBuilder in cluster-aware datasource
We want to provide users with API to obtain connection pointing to a specific shard. In general java.sql package this is done via ConnectionBuilder interface as shown in the article.
So cluster-aware API may look similarly
PicodataClusterAwareDatasource ds = new PicodataClusterAwareDatasource();
PicodataSharding shardingKey = ds.createShardingKeyBuilder(...)
.subkey("PITTSBURGH_BRANCH", JDBCType.VARCHAR)
.build();
Connection con = ds.createConnectionBuilder()
.user("rafa")
.password("tennis")
.setShardingKey(shardingKey)
.build(); // take connection from pool and return handle