Skip to content

Commit

Permalink
Merge pull request #219 from benjchristensen/context-constructors
Browse files Browse the repository at this point in the history
Restore HystrixContext* Constructors without ConcurrencyStrategy
  • Loading branch information
benjchristensen committed Mar 11, 2014
2 parents f3ee85c + 07cdcfa commit d37a4ed
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import rx.functions.Action1;
import rx.functions.Func2;

import com.netflix.hystrix.strategy.HystrixPlugins;
import com.netflix.hystrix.strategy.concurrency.HystrixContextScheduler.HystrixContextInnerScheduler;

/**
Expand Down Expand Up @@ -51,6 +52,10 @@ public class HystrixContexSchedulerAction implements Action1<Inner> {
*/
private final AtomicReference<Inner> t1Holder = new AtomicReference<Inner>();

public HystrixContexSchedulerAction(Action1<Inner> action) {
this(HystrixPlugins.getInstance().getConcurrencyStrategy(), action);
}

public HystrixContexSchedulerAction(final HystrixConcurrencyStrategy concurrencyStrategy, Action1<Inner> action) {
this.actual = action;
this.parentThreadState = HystrixRequestContext.getContextForCurrentThread();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

import java.util.concurrent.Callable;

import com.netflix.hystrix.strategy.HystrixPlugins;

/**
* Wrapper around {@link Callable} that manages the {@link HystrixRequestContext} initialization and cleanup for the execution of the {@link Callable}
*
Expand All @@ -30,6 +32,10 @@ public class HystrixContextCallable<K> implements Callable<K> {
private final Callable<K> actual;
private final HystrixRequestContext parentThreadState;

public HystrixContextCallable(Callable<K> actual) {
this(HystrixPlugins.getInstance().getConcurrencyStrategy(), actual);
}

public HystrixContextCallable(HystrixConcurrencyStrategy concurrencyStrategy, Callable<K> actual) {
this.actual = concurrencyStrategy.wrapCallable(actual);
this.parentThreadState = HystrixRequestContext.getContextForCurrentThread();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

import java.util.concurrent.Callable;

import com.netflix.hystrix.strategy.HystrixPlugins;

/**
* Wrapper around {@link Runnable} that manages the {@link HystrixRequestContext} initialization and cleanup for the execution of the {@link Runnable}
*
Expand All @@ -27,6 +29,10 @@ public class HystrixContextRunnable implements Runnable {
private final Callable<Void> actual;
private final HystrixRequestContext parentThreadState;

public HystrixContextRunnable(Runnable actual) {
this(HystrixPlugins.getInstance().getConcurrencyStrategy(), actual);
}

public HystrixContextRunnable(HystrixConcurrencyStrategy concurrencyStrategy, final Runnable actual) {
this.actual = concurrencyStrategy.wrapCallable(new Callable<Void>() {

Expand Down

0 comments on commit d37a4ed

Please sign in to comment.