-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #318 from benjchristensen/async-observable
HystrixAsyncCommand and HystrixObservableCommand
- Loading branch information
Showing
41 changed files
with
9,385 additions
and
1,627 deletions.
There are no files selected for viewing
925 changes: 665 additions & 260 deletions
925
...etflix/hystrix/HystrixExecutableBase.java → .../com/netflix/hystrix/AbstractCommand.java
Large diffs are not rendered by default.
Oops, something went wrong.
537 changes: 537 additions & 0 deletions
537
hystrix-core/src/main/java/com/netflix/hystrix/HystrixAsyncCommand.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
491 changes: 250 additions & 241 deletions
491
hystrix-core/src/main/java/com/netflix/hystrix/HystrixCommand.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
hystrix-core/src/main/java/com/netflix/hystrix/HystrixExecutableInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
hystrix-core/src/main/java/com/netflix/hystrix/HystrixInvokable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.netflix.hystrix; | ||
|
||
/** | ||
* Marker interface for Hystrix commands that can be invoked. | ||
*/ | ||
public interface HystrixInvokable<R> { | ||
|
||
} |
96 changes: 96 additions & 0 deletions
96
hystrix-core/src/main/java/com/netflix/hystrix/HystrixObservable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/** | ||
* 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 <R> | ||
*/ | ||
public interface HystrixObservable<R> extends HystrixInvokable<R> { | ||
|
||
/** | ||
* Used for asynchronous execution of command with a callback by subscribing to the {@link Observable}. | ||
* <p> | ||
* This eagerly starts execution of the command the same as {@link #queue()} and {@link #execute()}. | ||
* <p> | ||
* A lazy {@link Observable} can be obtained from {@link #toObservable()}. | ||
* <p> | ||
* <b>Callback Scheduling</b> | ||
* <p> | ||
* <ul> | ||
* <li>When using {@link ExecutionIsolationStrategy#THREAD} this defaults to using {@link Schedulers#threadPoolForComputation()} for callbacks.</li> | ||
* <li>When using {@link ExecutionIsolationStrategy#SEMAPHORE} this defaults to using {@link Schedulers#immediate()} for callbacks.</li> | ||
* </ul> | ||
* Use {@link HystrixCommand#toObservable(rx.Scheduler)} or {@link HystrixCollapser#toObservable(rx.Scheduler)} to schedule the callback differently. | ||
* <p> | ||
* See https://github.com/ReactiveX/RxJava/wiki for more information. | ||
* | ||
* @return {@code Observable<R>} that executes and calls back with the result of {@link #run()} execution or a fallback from {@link #getFallback()} if the command fails for any reason. | ||
* @throws HystrixRuntimeException | ||
* if a fallback does not exist | ||
* <p> | ||
* <ul> | ||
* <li>via {@code Observer#onError} if a failure occurs</li> | ||
* <li>or immediately if the command can not be queued (such as short-circuited, thread-pool/semaphore rejected)</li> | ||
* </ul> | ||
* @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<R> observe(); | ||
|
||
/** | ||
* Used for asynchronous execution of command with a callback by subscribing to the {@link Observable}. | ||
* <p> | ||
* This lazily starts execution of the command only once the {@link Observable} is subscribed to. | ||
* <p> | ||
* An eager {@link Observable} can be obtained from {@link #observe()} | ||
* <p> | ||
* <b>Callback Scheduling</b> | ||
* <p> | ||
* <ul> | ||
* <li>When using {@link ExecutionIsolationStrategy#THREAD} this defaults to using {@link Schedulers#threadPoolForComputation()} for callbacks.</li> | ||
* <li>When using {@link ExecutionIsolationStrategy#SEMAPHORE} this defaults to using {@link Schedulers#immediate()} for callbacks.</li> | ||
* </ul> | ||
* Use {@link HystrixCommand#toObservable(rx.Scheduler)} or {@link HystrixCollapser#toObservable(rx.Scheduler)} to schedule the callback differently. | ||
* <p> | ||
* See https://github.com/ReactiveX/RxJava/wiki for more information. | ||
* | ||
* @return {@code Observable<R>} that executes and calls back with the result of {@link #run()} execution or a fallback from {@link #getFallback()} if the command fails for any reason. | ||
* @throws HystrixRuntimeException | ||
* if a fallback does not exist | ||
* <p> | ||
* <ul> | ||
* <li>via {@code Observer#onError} if a failure occurs</li> | ||
* <li>or immediately if the command can not be queued (such as short-circuited, thread-pool/semaphore rejected)</li> | ||
* </ul> | ||
* @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<R> toObservable(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.