use of io.atomix.core.list.AsyncDistributedList in project atomix by atomix.
the class DefaultDistributedListBuilder method buildAsync.
@Override
@SuppressWarnings("unchecked")
public CompletableFuture<DistributedList<E>> buildAsync() {
return newProxy(DistributedListService.class, new ServiceConfig()).thenCompose(proxy -> new DistributedListProxy(proxy, managementService.getPrimitiveRegistry()).connect()).thenApply(rawList -> {
Serializer serializer = serializer();
AsyncDistributedList<E> list = new TranscodingAsyncDistributedList<>(rawList, element -> BaseEncoding.base16().encode(serializer.encode(element)), string -> serializer.decode(BaseEncoding.base16().decode(string)));
if (config.getCacheConfig().isEnabled()) {
list = new CachingAsyncDistributedList<>(list, config.getCacheConfig());
}
if (config.isReadOnly()) {
list = new UnmodifiableAsyncDistributedList<>(list);
}
return list.sync();
});
}
Aggregations