All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.netflix.hystrix.HystrixObservable Maven / Gradle / Ivy

There is a newer version: 1.5.18
Show newest version
/**
 * Copyright 2014 Netflix, Inc.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.netflix.hystrix;

import rx.Observable;
import rx.schedulers.Schedulers;

import com.netflix.hystrix.HystrixCommandProperties.ExecutionIsolationStrategy;
import com.netflix.hystrix.exception.HystrixBadRequestException;
import com.netflix.hystrix.exception.HystrixRuntimeException;

/**
 * Common interface for executables that implement the Observable methods {@link #observe()} and {@link #toObservable()} so client code can treat them the same and combine in typed collections if desired.
 * 
 * @param 
 */
public interface HystrixObservable extends HystrixInvokable {

    /**
     * Used for asynchronous execution of command with a callback by subscribing to the {@link Observable}.
     * 

* This eagerly starts execution of the command the same as {@link HystrixCommand#queue()} and {@link HystrixCommand#execute()}. *

* A lazy {@link Observable} can be obtained from {@link #toObservable()}. *

* Callback Scheduling *

*

    *
  • When using {@link ExecutionIsolationStrategy#THREAD} this defaults to using {@link Schedulers#computation()} for callbacks.
  • *
  • When using {@link ExecutionIsolationStrategy#SEMAPHORE} this defaults to using {@link Schedulers#immediate()} for callbacks.
  • *
*

* See https://github.com/ReactiveX/RxJava/wiki for more information. * * @return {@code Observable} that executes and calls back with the result of the command execution or a fallback if the command execution fails for any reason. * @throws HystrixRuntimeException * if a fallback does not exist *

*

    *
  • via {@code Observer#onError} if a failure occurs
  • *
  • or immediately if the command can not be queued (such as short-circuited, thread-pool/semaphore rejected)
  • *
* @throws HystrixBadRequestException * via {@code Observer#onError} if invalid arguments or state were used representing a user failure, not a system failure * @throws IllegalStateException * if invoked more than once */ public Observable observe(); /** * Used for asynchronous execution of command with a callback by subscribing to the {@link Observable}. *

* This lazily starts execution of the command only once the {@link Observable} is subscribed to. *

* An eager {@link Observable} can be obtained from {@link #observe()} *

* Callback Scheduling *

*

    *
  • When using {@link ExecutionIsolationStrategy#THREAD} this defaults to using {@link Schedulers#computation()} for callbacks.
  • *
  • When using {@link ExecutionIsolationStrategy#SEMAPHORE} this defaults to using {@link Schedulers#immediate()} for callbacks.
  • *
*

* See https://github.com/ReactiveX/RxJava/wiki for more information. * * @return {@code Observable} that executes and calls back with the result of the command execution or a fallback if the command execution fails for any reason. * @throws HystrixRuntimeException * if a fallback does not exist *

*

    *
  • via {@code Observer#onError} if a failure occurs
  • *
  • or immediately if the command can not be queued (such as short-circuited, thread-pool/semaphore rejected)
  • *
* @throws HystrixBadRequestException * via {@code Observer#onError} if invalid arguments or state were used representing a user failure, not a system failure * @throws IllegalStateException * if invoked more than once */ public Observable toObservable(); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy