public static NodesCatalogCache newCache(final CatalogClient catalogClient) { CacheConfig cacheConfig = catalogClient.getConfig().getCacheConfig(); int watchSeconds = Ints.checkedCast(cacheConfig.getWatchDuration().getSeconds()); return newCache(catalogClient, QueryOptions.BLANK, watchSeconds); }
public static ServiceCatalogCache newCache(final CatalogClient catalogClient, final String serviceName) { CacheConfig cacheConfig = catalogClient.getConfig().getCacheConfig(); int watchSeconds = Ints.checkedCast(cacheConfig.getWatchDuration().getSeconds()); return newCache(catalogClient, serviceName, QueryOptions.BLANK, watchSeconds); } }
public static NodesCatalogCache newCache( final CatalogClient catalogClient, final QueryOptions queryOptions, final int watchSeconds) { final CallbackConsumer<Node> callbackConsumer = (index, callback) -> catalogClient.getNodes(watchParams(index, watchSeconds, queryOptions), callback); return new NodesCatalogCache(Node::getNode, callbackConsumer, catalogClient.getConfig().getCacheConfig(), catalogClient.getEventHandler()); }
public static ServiceCatalogCache newCache( final CatalogClient catalogClient, final String serviceName, final QueryOptions queryOptions, final int watchSeconds) { final CallbackConsumer<CatalogService> callbackConsumer = (index, callback) -> catalogClient.getService(serviceName, watchParams(index, watchSeconds, queryOptions), callback); CacheDescriptor cacheDescriptor = new CacheDescriptor("catalog.service", serviceName); return new ServiceCatalogCache(CatalogService::getServiceId, callbackConsumer, catalogClient.getConfig().getCacheConfig(), catalogClient.getEventHandler(), cacheDescriptor); }