This is a simple helper library to configure Hystrix with ease without having to write plumbing code. This library compiles only on Java 8.
- Hystrix 1.5.3
Configuring Hystrix environment requires one to write a lot of plumbing code. Using this helper library it is very easy to feed in configuration into Hystrix runtime
-
Clone the source:
git clone github.com/phaneesh/hystrix-configurator
-
Build
mvn install
Use the following repository:
<repository>
<id>clojars</id>
<name>Clojars repository</name>
<url>https://clojars.org/repo</url>
</repository>
Use the following maven dependency:
<dependency>
<groupId>com.hystrix</groupId>
<artifactId>hystrix-configurator</artifactId>
<version>0.0.6</version>
</dependency>
HystrixConfigurationFactory.init(
HystrixConfig.builder()
.defaultConfig(HystrixDefaultConfig.builder().build())
.command(HystrixCommandConfig.builder().name("test").build())
.build());
SimpleTestCommand command = new SimpleTestCommand();
String result = command.queue().get();
public class SimpleTestCommand extends BaseCommand<String> {
public SimpleTestCommand() {
super("test");
}
@Override
protected String run() throws Exception {
return "Simple Test";
}
}
HystrixConfigurationFactory.init(
HystrixConfig.builder()
.defaultConfig(HystrixDefaultConfig.builder().build())
.command(HystrixCommandConfig.builder().name("test").build())
.build());
SimpleTestCommand command = new SimpleTestCommand();
String result = command.queue().get();
public class SimpleTestCommand extends HystrixCommand<String> {
public SimpleTestCommand() {
super(HystrixCommandGroupKey.Factory.asKey("test"));
}
@Override
protected String run() throws Exception {
return "Simple Test";
}
}
Copyright 2016 Phaneesh Nagaraja [email protected].
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.