-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
55 changed files
with
3,936 additions
and
1,222 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" inherit-compiler-output="false"> | ||
<output url="file://$MODULE_DIR$/target/classes" /> | ||
<output-test url="file://$MODULE_DIR$/target/test-classes" /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" isTestSource="false" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" /> | ||
<excludeFolder url="file://$MODULE_DIR$/target" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
<orderEntry type="library" name="Maven: com.netflix.hystrix:hystrix-core:1.3.13" level="project" /> | ||
<orderEntry type="library" name="Maven: com.netflix.rxjava:rxjava-core:0.16.1" level="project" /> | ||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.0" level="project" /> | ||
<orderEntry type="library" name="Maven: com.netflix.archaius:archaius-core:0.4.1" level="project" /> | ||
<orderEntry type="library" name="Maven: commons-configuration:commons-configuration:1.8" level="project" /> | ||
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" /> | ||
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.1.1" level="project" /> | ||
<orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:2.0.0" level="project" /> | ||
<orderEntry type="library" name="Maven: junit:junit:4.12" level="project" /> | ||
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" /> | ||
</component> | ||
</module> | ||
|
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,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>Hystrix</groupId> | ||
<artifactId>Hystrix</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.netflix.hystrix</groupId> | ||
<artifactId>hystrix-core</artifactId> | ||
<version>1.3.13</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.12</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
70 changes: 70 additions & 0 deletions
70
...l/Hystrix/Hystrix/src/main/java/com/netflix/hystrix/examples/basic/CommandHelloWorld.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,70 @@ | ||
/** | ||
* Copyright 2012 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.examples.basic; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
import java.util.concurrent.Future; | ||
|
||
import org.junit.Test; | ||
|
||
import com.netflix.hystrix.HystrixCommand; | ||
import com.netflix.hystrix.HystrixCommandGroupKey; | ||
|
||
/** | ||
* The obligatory "Hello World!" showing a simple implementation of a {@link com.netflix.hystrix.HystrixCommand}. | ||
*/ | ||
public class CommandHelloWorld extends HystrixCommand<String> { | ||
|
||
private final String name; | ||
|
||
public CommandHelloWorld(String name) { | ||
super(HystrixCommandGroupKey.Factory.asKey("ExampleGroup")); | ||
this.name = name; | ||
} | ||
|
||
@Override | ||
protected String run() { | ||
return "Hello " + name + "!"; | ||
} | ||
|
||
public static class UnitTest { | ||
|
||
@Test | ||
public void testSynchronous() { | ||
assertEquals("Hello World!", new CommandHelloWorld("World").execute()); | ||
assertEquals("Hello Bob!", new CommandHelloWorld("Bob").execute()); | ||
} | ||
|
||
@Test | ||
public void testAsynchronous1() throws Exception { | ||
assertEquals("Hello World!", new CommandHelloWorld("World").queue().get()); | ||
assertEquals("Hello Bob!", new CommandHelloWorld("Bob").queue().get()); | ||
} | ||
|
||
@Test | ||
public void testAsynchronous2() throws Exception { | ||
|
||
Future<String> fWorld = new CommandHelloWorld("World").queue(); | ||
Future<String> fBob = new CommandHelloWorld("Bob").queue(); | ||
|
||
assertEquals("Hello World!", fWorld.get()); | ||
assertEquals("Hello Bob!", fBob.get()); | ||
} | ||
|
||
} | ||
|
||
} |
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.