@Override public Observable<RibbonResponse<Observable<T>>> observe() { RibbonHystrixObservableCommand<T> hystrixCommand = request.createHystrixCommand(); ReplaySubject<T> subject = ReplaySubject.create(); hystrixCommand.getObservable().subscribe(subject); return convertToRibbonResponse(subject, hystrixCommand); }
@Override public Future<RibbonResponse<T>> queue() { final RibbonHystrixObservableCommand<T> hystrixCommand = request.createHystrixCommand(); final Future<T> f = hystrixCommand.getObservable().toBlocking().toFuture(); return new Future<RibbonResponse<T>>() { @Override public boolean cancel(boolean arg0) { return f.cancel(arg0); } @Override public RibbonResponse<T> get() throws InterruptedException, ExecutionException { final T obj = f.get(); return new HttpMetaResponse<T>(obj, hystrixCommand); } @Override public RibbonResponse<T> get(long arg0, TimeUnit arg1) throws InterruptedException, ExecutionException, TimeoutException { final T obj = f.get(arg0, arg1); return new HttpMetaResponse<T>(obj, hystrixCommand); } @Override public boolean isCancelled() { return f.isCancelled(); } @Override public boolean isDone() { return f.isDone(); } }; }
@Override public Observable<RibbonResponse<Observable<T>>> toObservable() { RibbonHystrixObservableCommand<T> hystrixCommand = request.createHystrixCommand(); final Observable<T> output = hystrixCommand.toObservable(); return convertToRibbonResponse(output, hystrixCommand); }
@Override public RibbonResponse<T> execute() { RibbonHystrixObservableCommand<T> hystrixCommand = request.createHystrixCommand(); T obj = hystrixCommand.getObservable().toBlocking().last(); return new HttpMetaResponse<T>(obj, hystrixCommand); }