Skip to content

Commit

Permalink
Add a new interface, DefaultRequestLogStrategy, to disable requestL…
Browse files Browse the repository at this point in the history
…og for the concurrency strategy.

This adds an opt-in interface to allow concurrency strategies to
behave like the default concurrency strategy.
  • Loading branch information
axiak committed Mar 24, 2015
1 parent 75f5c3b commit 9b74fdb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;

import com.netflix.hystrix.strategy.concurrency.DefaultRequestLogStrategy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -258,7 +259,7 @@ protected AbstractCommand(HystrixCommandGroupKey group, HystrixCommandKey key, H
this.requestCache = HystrixRequestCache.getInstance(this.commandKey, this.concurrencyStrategy);

/* store reference to request log regardless of which thread later hits it */
if (concurrencyStrategy instanceof HystrixConcurrencyStrategyDefault) {
if (concurrencyStrategy instanceof DefaultRequestLogStrategy) {
// if we're using the default we support only optionally using a request context
if (HystrixRequestContext.isCurrentThreadInitialized()) {
currentRequestLog = HystrixRequestLog.getCurrentRequest(concurrencyStrategy);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.netflix.hystrix.strategy.concurrency;

/**
* Indicates that the HystrixConcurrencyStrategy does not use a custom request log,
* therefore threads do not need to initialize the request log.
*/
public interface DefaultRequestLogStrategy {
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
* @ExcludeFromJavadoc
*/
public class HystrixConcurrencyStrategyDefault extends HystrixConcurrencyStrategy {
public class HystrixConcurrencyStrategyDefault extends HystrixConcurrencyStrategy implements DefaultRequestLogStrategy {

private static HystrixConcurrencyStrategyDefault INSTANCE = new HystrixConcurrencyStrategyDefault();

Expand Down

0 comments on commit 9b74fdb

Please sign in to comment.