我正在尝试将hystrixJS配置为我的一个nodejs应用程序.我想结束我的应用程序正在制作的几个外部依赖项. https://www.npmjs.com/package/hystrixjs
我读了自述文件,但我仍然无法得到如何用这个hystrix包装我的依赖调用以及如何为此配置仪表板.如果有人已经尝试过这个,请给我一些指示.
谢谢.
小智 8
您可以在repo 中的示例应用程序中找到示例.但也可以随意提交关于bitbucket的问题,我将尝试提供更多示例.
通常,您可以包装任何返回promise的函数,它不必是http请求,尽管它是最常见的用例.
仪表板不是hystrix本身的一部分.它的工作方式,您可以在本地运行仪表板,查看此处的说明,然后将端点添加到您的应用程序以公开指标.示例应用程序显示了如何执行此操作:
function hystrixStreamResponse(request, response) {
response.append('Content-Type', 'text/event-stream;charset=UTF-8');
response.append('Cache-Control', 'no-cache, no-store, max-age=0, must-revalidate');
response.append('Pragma', 'no-cache');
return hystrixStream.toObservable().subscribe(
function onNext(sseData) {
response.write('data: ' + sseData + '\n\n');
},
function onError(error) {console.log(error);
},
function onComplete() {
return response.end();
}
);
};
app.get('/api/hystrix.stream', hystrixStreamResponse);
Run Code Online (Sandbox Code Playgroud)
然后,您可以将URL粘贴到仪表板中,它将显示您的命令.
如果有帮助,请告诉我
| 归档时间: |
|
| 查看次数: |
3935 次 |
| 最近记录: |