Skip to content

Commit

Permalink
Support RibbonCommand group key parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
mattnelson committed Oct 5, 2015
1 parent 16628f6 commit e6e821a
Showing 1 changed file with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.netflix.client.http.HttpResponse;
import com.netflix.config.DynamicPropertyFactory;
import com.netflix.hystrix.HystrixCommand;
import com.netflix.hystrix.HystrixCommandKey;
import com.netflix.hystrix.HystrixCommandGroupKey;
import com.netflix.hystrix.HystrixCommandProperties;
import com.netflix.niws.client.http.RestClient;
Expand Down Expand Up @@ -53,13 +54,25 @@ public RibbonCommand(String commandKey,
MultivaluedMap<String, String> params,
InputStream requestEntity) throws URISyntaxException {

super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey(commandKey)).andCommandPropertiesDefaults(
// we want to default to semaphore-isolation since this wraps
// 2 others commands that are already thread isolated
HystrixCommandProperties.Setter().withExecutionIsolationStrategy(HystrixCommandProperties.ExecutionIsolationStrategy.SEMAPHORE)
.withExecutionIsolationSemaphoreMaxConcurrentRequests(DynamicPropertyFactory.getInstance().
getIntProperty(ZuulConstants.ZUUL_EUREKA + commandKey + ".semaphore.maxSemaphores", 100).get())));

this("default", RibbonCommand.class.getSimpleName(), restClient, verb, uri, headers, params, requestEntity);
}

public RibbonCommand(String groupKey,
String commandKey,
RestClient restClient,
Verb verb,
String uri,
MultivaluedMap<String, String> headers,
MultivaluedMap<String, String> params,
InputStream requestEntity) throws URISyntaxException {

super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey(groupKey)).andCommandKey(HystrixCommandKey.Factory.asKey(commandKey)).andCommandPropertiesDefaults(
// we want to default to semaphore-isolation since this wraps
// 2 others commands that are already thread isolated
HystrixCommandProperties.Setter().withExecutionIsolationStrategy(HystrixCommandProperties.ExecutionIsolationStrategy.SEMAPHORE)
.withExecutionIsolationSemaphoreMaxConcurrentRequests(DynamicPropertyFactory.getInstance().
getIntProperty(ZuulConstants.ZUUL_EUREKA + commandKey + ".semaphore.maxSemaphores", 100).get())));

this.restClient = restClient;
this.verb = verb;
this.uri = new URI(uri);
Expand Down

0 comments on commit e6e821a

Please sign in to comment.