1616 */
1717package feast .serving .config ;
1818
19- import com .fasterxml . jackson . core . JsonProcessingException ;
20- import com .google .protobuf . InvalidProtocolBufferException ;
19+ import com .google . cloud . bigtable . data . v2 . BigtableDataClient ;
20+ import com .google .cloud . bigtable . data . v2 . BigtableDataSettings ;
2121import feast .serving .service .OnlineServingServiceV2 ;
2222import feast .serving .service .ServingServiceV2 ;
2323import feast .serving .specs .CachedSpecService ;
2424import feast .storage .api .retriever .OnlineRetrieverV2 ;
25+ import feast .storage .connectors .bigtable .retriever .BigTableOnlineRetriever ;
26+ import feast .storage .connectors .bigtable .retriever .BigTableStoreConfig ;
2527import feast .storage .connectors .redis .retriever .*;
2628import io .opentracing .Tracer ;
29+ import java .io .IOException ;
2730import org .slf4j .Logger ;
31+ import org .springframework .beans .factory .annotation .Autowired ;
32+ import org .springframework .context .ApplicationContext ;
2833import org .springframework .context .annotation .Bean ;
2934import org .springframework .context .annotation .Configuration ;
35+ import org .springframework .context .annotation .Lazy ;
3036
3137@ Configuration
3238public class ServingServiceConfigV2 {
3339 private static final Logger log = org .slf4j .LoggerFactory .getLogger (ServingServiceConfigV2 .class );
3440
41+ @ Autowired private ApplicationContext context ;
42+
43+ @ Bean
44+ @ Lazy (true )
45+ public BigtableDataClient bigtableClient (FeastProperties feastProperties ) throws IOException {
46+ BigTableStoreConfig config = feastProperties .getActiveStore ().getBigtableConfig ();
47+ String projectId = config .getProjectId ();
48+ String instanceId = config .getInstanceId ();
49+
50+ return BigtableDataClient .create (
51+ BigtableDataSettings .newBuilder ()
52+ .setProjectId (projectId )
53+ .setInstanceId (instanceId )
54+ .build ());
55+ }
56+
3557 @ Bean
3658 public ServingServiceV2 servingServiceV2 (
37- FeastProperties feastProperties , CachedSpecService specService , Tracer tracer )
38- throws InvalidProtocolBufferException , JsonProcessingException {
59+ FeastProperties feastProperties , CachedSpecService specService , Tracer tracer ) {
3960 ServingServiceV2 servingService = null ;
4061 FeastProperties .Store store = feastProperties .getActiveStore ();
4162
@@ -51,6 +72,11 @@ public ServingServiceV2 servingServiceV2(
5172 OnlineRetrieverV2 redisRetriever = new OnlineRetriever (redisClient );
5273 servingService = new OnlineServingServiceV2 (redisRetriever , specService , tracer );
5374 break ;
75+ case BIGTABLE :
76+ BigtableDataClient bigtableClient = context .getBean (BigtableDataClient .class );
77+ OnlineRetrieverV2 bigtableRetriever = new BigTableOnlineRetriever (bigtableClient );
78+ servingService = new OnlineServingServiceV2 (bigtableRetriever , specService , tracer );
79+ break ;
5480 }
5581
5682 return servingService ;
0 commit comments