转自:http://youdang.github.io/2016/02/01/translate-hystrix-wiki-getting-started/
如何获取
二进制包和使用 Maven, Ivy, Gradle 或其他项目管理工具所需的依赖配置信息放置在 http://search.maven.org。
Maven 配置的例子:
1
2
3
4
5
|
<dependency>
<groupId>com.netflix.hystrix</groupId>
<artifactId>hystrix-core</artifactId>
<version>x.y.z</version>
</dependency>
|
Ivy 配置的例子:
1
|
<dependency org="com.netflix.hystrix" name="hystrix-core" rev="x.y.z" />
|
若你仅仅需要下载 jar 包,而不需要使用构建工具,那么你需要创建如下所示的一个 Maven pom 文件,并指定需要下载的版本:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
<?xml version="1.0"?>
<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>com.netflix.hystrix.download</groupId>
<artifactId>hystrix-download</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Simple POM to download hystrix-core and dependencies</name>
<url>http://github.com/Netflix/Hystrix</url>
<dependencies>
<dependency>
<groupId>com.netflix.hystrix</groupId>
<artifactId>hystrix-core</artifactId>
<version>x.y.z</version>
<scope/>
</dependency>
</dependencies>
</project>
|
然后执行如下命令:
1
|
mvn -f download-hystrix-pom.xml dependency:copy-dependencies
|
hystrix-core-*.jar 及其依赖的包会被下载到 ./target/dependency/ 目录下。
Hystrix 依赖 Java 6 或更高版本。
Hello World!
下面是使用 Hystrix 最简单的一个例子:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
public class CommandHelloWorld extends HystrixCommand<String> {
private final String name;
public CommandHelloWorld(String name) {
super(HystrixCommandGroupKey.Factory.asKey("ExampleGroup"));
this.name = name;
}
protected String run() {
// a real example would do work like a network call here
return "Hello " + name + "!";
}
}
|
上述代码定义的『命令』的使用方式如下:
1
2
3
|
String s = new CommandHelloWorld("Bob").execute();
Future<String> s = new CommandHelloWorld("Bob").queue();
Observable<String> s = new CommandHelloWorld("Bob").observe();
|
更多的例子和说明请移步 如何使用 一章。
从源码构建
从 GitHub 上获得源码,然后执行如下命令进行构建:
1
2
3
|
$ git clone git@github.com:Netflix/Hystrix.git
$ cd Hystrix/
$ ./gradlew build
|
若想重新开始构建:
1
|
$ ./gradlew clean build
|
构建可能的输出如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
$ ./gradlew build
:hystrix-core:compileJava
:hystrix-core:processResources UP-TO-DATE
:hystrix-core:classes
:hystrix-core:jar
:hystrix-core:sourcesJar
:hystrix-core:signArchives SKIPPED
:hystrix-core:assemble
:hystrix-core:licenseMain UP-TO-DATE
:hystrix-core:licenseTest UP-TO-DATE
:hystrix-core:compileTestJava
:hystrix-core:processTestResources UP-TO-DATE
:hystrix-core:testClasses
:hystrix-core:test
:hystrix-core:check
:hystrix-core:build
:hystrix-examples:compileJava
:hystrix-examples:processResources UP-TO-DATE
:hystrix-examples:classes
:hystrix-examples:jar
:hystrix-examples:sourcesJar
:hystrix-examples:signArchives SKIPPED
:hystrix-examples:assemble
:hystrix-examples:licenseMain UP-TO-DATE
:hystrix-examples:licenseTest UP-TO-DATE
:hystrix-examples:compileTestJava
:hystrix-examples:processTestResources UP-TO-DATE
:hystrix-examples:testClasses
:hystrix-examples:test
:hystrix-examples:check
:hystrix-examples:build
BUILD SUCCESSFUL
Total time: 30.758 secs
|
重新构建的话,所有单元测试都会被执行,输出如下:
1
|
> Building > :hystrix-core:test > 147 tests completed
|
相关推荐
Hystrix-dashboard+turbine-web+说明文档,用于Hystrix项目的监控、多实例的聚合监控
文档中关于Hystrix相关的学习笔记及调试截图,想学原理的很适合
- 使用SpringFox生成API文档 - 提供Swagger-UI可测试API界面 - 提供独立的HTML静态文档生成模块 - logback分别打印-info与-error双日志 - ExceptionHandler统一异常处理 - Hystrix服务融断及降级 - 选用较繁琐的...
讲述hytrix的原理及相关配置,对hytrix的容错机制、降级机制、熔断机制、限流机制以及服务治理等作出详细说明。
Hystrix官网的原理介绍以及使用介绍非常详细,非常建议看一遍,地址见参考文档部分。1Hystrix能做什么通过hystrix可以解决雪崩效应问题,它提供了资源隔离、降级机制、融断、缓存等功能。资源隔离:包括线程池隔离和...
spring cloud 组件整合 eureka gateway feign hystrix,各个模的整合,供大家一起学习
在上了解有关Hystrix和其他断路器解决的问题的更多。 优点的简短摘要是: 下游服务失败,所有请求永久挂起。 没有电路,您的服务也将永远挂起。 因为您有电路,所以可以快速检测到此故障,并且可以在等待下游服务...
springCloud项目基础demo全部文件夹,包括文档桌面,代码中有说明与注释,附带参考的博客地址 项目文件夹介绍: springcloud-eureka ---注册中心(核心)参考博客地址: ... client ---- feign方式调用demo项目 参考...
微信商城+微信公众号开发,该项目根据上海某大型知名电商企业互联网互联网项目,改版而来,使用最新微服务架构技术,页面使用高仿小米界面。功能包含电商模块,会员、SSO、订单、商品、支付、消息、微信、H5和PC、...
lamp-cloud微服务脚手架的前身是zuihou-admin-cloud,从3.0.0版本开始,改名为lamp-cloud,它是lamp项目的其中一员。 lamp-cloud微服务脚手架是一个基于SpringCloud(Hoxton.SR10) + SpringBoot(2.3.10.RELEASE)的...
005-接入Hystrix断路器,实现服务的熔断与降级; 006-接入Hystrix-Dashboard,实现微服务监控; 007-接入zuul,实现服务的代理、路由、过滤; 008-接入config,实现服务端的配置; 009-接入config,实现客户端的配置...
Tourine 将指标公开为 Hystrix 事件流中的“Hystrix 命令”,以便与 Hystrix 仪表板一起使用。 使用 ,可以将 Tourine 提要与 Hystrix 事件流聚合以提供统一视图。 完整文档 有关完整的文档和示例,请参阅 。 ##...
厚脸皮 受 Netflix 的 Hystrix 启发的延迟和容错 Python 库。 自由软件:MIT 许可证 安装 pip install thickskin 文档 发展 要运行所有测试,请运行: tox
谷粒学院全栈开发项目 GitHub 项目下载 ...除此之外,项目中使用了阿里巴巴的EasyExcel实现对Excel的读写操作,使用了Redis进行首页数据的缓存,使用Git进行代码的版本控制,还整合了Swagger生成接口文档 。
spring boot 实践学习案例,与其它组件结合如 mybatis、jpa、dubbo、redis、mongodb、memcached、kafka、... - Spring Cloud 入门,包括 Eureka(服务注册与发现)、Config(配置中心)、Hystrix(断路器)、Bus(消息总线) 等
个人学习练习demo,对应Blog:springCloud学习【二】:服务熔断:Hystrix容错框架【实例】,里面是完整的demo包,registry是注册中心模块,service是服务提供者,consume和consume-feign是消费服务的两种实现方式,...
springcloud基础文档,内涵框架技术的整合,Eureka、熔断器Hystrix和监控工具、配置中心、服务网关zuul、链路跟踪(我们公司最终是用nacos作为配置中心和服务中心,有技术问题可私信)
每个示例都带有详细的介绍文档、作者在使用过程中踩过的坑、解决方案及参考资料,方便快速上手为你提供学习捷径,少绕弯路,提高开发效率。 有需要写关于spring boot、spring cloud示例,可以给我提issue哦 ##...
安装节点模块npm install 启动模拟服务器: npm run mock-server 启动应用程序: npm startHystrix仪表板该应用程序将流显示在路径/hystrix.stream 有关如何启动请参考文档。 仪表板运行后,将其打开并将URL设置为...