示例#1
0
 @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);
 }
示例#2
0
  @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();
      }
    };
  }
示例#3
0
 @Override
 public Observable<RibbonResponse<Observable<T>>> toObservable() {
   RibbonHystrixObservableCommand<T> hystrixCommand = request.createHystrixCommand();
   final Observable<T> output = hystrixCommand.toObservable();
   return convertToRibbonResponse(output, hystrixCommand);
 }
示例#4
0
 @Override
 public RibbonResponse<T> execute() {
   RibbonHystrixObservableCommand<T> hystrixCommand = request.createHystrixCommand();
   T obj = hystrixCommand.getObservable().toBlocking().last();
   return new HttpMetaResponse<T>(obj, hystrixCommand);
 }