blob: 08c7369dea6d35f7aeeb1486704144c7dab16df7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
package org.onap.msb.apiroute.wrapper.consulextend.cache;
import java.math.BigInteger;
import org.apache.http.HttpEntity;
import org.onap.msb.apiroute.wrapper.consulextend.CatalogClient;
import org.onap.msb.apiroute.wrapper.consulextend.async.ConsulResponseCallback;
import com.orbitz.consul.option.CatalogOptions;
import com.orbitz.consul.option.QueryOptions;
public class ServicesCatalogCache extends ConsulCache<HttpEntity> {
private ServicesCatalogCache(CallbackConsumer<HttpEntity> callbackConsumer) {
super(callbackConsumer);
}
public static ServicesCatalogCache newCache(
final CatalogClient catalogClient,
final CatalogOptions catalogOptions,
final QueryOptions queryOptions,
final int watchSeconds) {
CallbackConsumer<HttpEntity> callbackConsumer = new CallbackConsumer<HttpEntity>() {
@Override
public void consume(BigInteger index, ConsulResponseCallback<HttpEntity> callback) {
QueryOptions params = watchParams(index, watchSeconds, queryOptions);
catalogClient.getServices(catalogOptions, params,callback);
}
};
return new ServicesCatalogCache(callbackConsumer);
}
public static ServicesCatalogCache newCache(final CatalogClient catalogClient) {
return newCache(catalogClient, CatalogOptions.BLANK, QueryOptions.BLANK, 10);
}
}
|