1 package org.onap.msb.apiroute.wrapper.consulextend.cache;
3 import java.math.BigInteger;
5 import org.apache.http.HttpEntity;
6 import org.onap.msb.apiroute.wrapper.consulextend.CatalogClient;
7 import org.onap.msb.apiroute.wrapper.consulextend.async.ConsulResponseCallback;
9 import com.orbitz.consul.option.CatalogOptions;
10 import com.orbitz.consul.option.QueryOptions;
12 public class ServicesCatalogCache extends ConsulCache<HttpEntity> {
14 private ServicesCatalogCache(CallbackConsumer<HttpEntity> callbackConsumer) {
15 super(callbackConsumer);
18 public static ServicesCatalogCache newCache(
19 final CatalogClient catalogClient,
20 final CatalogOptions catalogOptions,
21 final QueryOptions queryOptions,
22 final int watchSeconds) {
24 CallbackConsumer<HttpEntity> callbackConsumer = new CallbackConsumer<HttpEntity>() {
26 public void consume(BigInteger index, ConsulResponseCallback<HttpEntity> callback) {
27 QueryOptions params = watchParams(index, watchSeconds, queryOptions);
28 catalogClient.getServices(catalogOptions, params,callback);
32 return new ServicesCatalogCache(callbackConsumer);
36 public static ServicesCatalogCache newCache(final CatalogClient catalogClient) {
37 return newCache(catalogClient, CatalogOptions.BLANK, QueryOptions.BLANK, 10);