public void voidAsyncOpToBlocking(Func1<AsyncMap, Observable> asyncOp) { CompletableFuture<Void> future = new CompletableFuture<>(); rxVertx.sharedData().getClusterWideMapObservable(PAC4J_SHARED_DATA_KEY) .map(asyncOp) .subscribe(result -> future.complete(null)); try { future.get(blockingTimeoutSeconds, TimeUnit.SECONDS); } catch (InterruptedException|ExecutionException |TimeoutException e) { throw new TechnicalException(e); } } }
public void voidAsyncOpToBlocking(Func1<AsyncMap, Observable> asyncOp) { CompletableFuture<Void> future = new CompletableFuture<>(); rxVertx.sharedData().getClusterWideMapObservable(PAC4J_SHARED_DATA_KEY) .map(asyncOp) .subscribe(result -> future.complete(null)); try { future.get(blockingTimeoutSeconds, TimeUnit.SECONDS); } catch (InterruptedException|ExecutionException |TimeoutException e) { throw new TechnicalException(e); } } }
@Override public V get(K key) { voidAsyncOpToBlocking(map -> map.getObservable((key))); final CompletableFuture<V> valueFuture = new CompletableFuture<>(); rxVertx.sharedData().<K, V>getClusterWideMapObservable(PAC4J_SHARED_DATA_KEY) .flatMap(map -> map.getObservable(key)) .subscribe(valueFuture::complete); try { return valueFuture.get(blockingTimeoutSeconds, TimeUnit.SECONDS); } catch (InterruptedException|ExecutionException|TimeoutException e) { throw new TechnicalException(e); } }
@Override public V get(K key) { voidAsyncOpToBlocking(map -> map.getObservable((key))); final CompletableFuture<V> valueFuture = new CompletableFuture<>(); rxVertx.sharedData().<K, V>getClusterWideMapObservable(PAC4J_SHARED_DATA_KEY) .flatMap(map -> map.getObservable(key)) .subscribe(valueFuture::complete); try { return valueFuture.get(blockingTimeoutSeconds, TimeUnit.SECONDS); } catch (InterruptedException|ExecutionException|TimeoutException e) { throw new TechnicalException(e); } }