use of io.atomix.core.queue.DistributedQueue in project atomix by atomix.
the class DefaultDistributedQueueBuilder method buildAsync.
@Override
@SuppressWarnings("unchecked")
public CompletableFuture<DistributedQueue<E>> buildAsync() {
return newProxy(DistributedQueueService.class, new ServiceConfig()).thenCompose(proxy -> new DistributedQueueProxy(proxy, managementService.getPrimitiveRegistry()).connect()).thenApply(rawQueue -> {
Serializer serializer = serializer();
AsyncDistributedQueue<E> queue = new TranscodingAsyncDistributedQueue<>(rawQueue, element -> BaseEncoding.base16().encode(serializer.encode(element)), string -> serializer.decode(BaseEncoding.base16().decode(string)));
if (config.getCacheConfig().isEnabled()) {
queue = new CachingAsyncDistributedQueue<>(queue, config.getCacheConfig());
}
if (config.isReadOnly()) {
queue = new UnmodifiableAsyncDistributedQueue<>(queue);
}
return queue.sync();
});
}
Aggregations