hydra nodejs 微服务框架简单试用
hydra 是一个以来redis 的nodejs 微服务框架
安装
需要redis,使用docker 进行运行
- redis
docker run -d -p 6379:6379 redis
- 安装yo && hydra-cli
sudo npm install -g yo generator-fwsp-hydra hydra-cli
配置redis 环境
instance 名称随意,具体环境配置即可
hydra-cli config dalong
redisUrl: 127.0.0.1
redisPort: 6379
redisDb: 15
使用脚手架工具,生成demo
yo fwsp-hydra
fwsp-hydra generator v0.3.1 yeoman-generator v3.0.0 yo v2.0.4
? Name of the service (`-service` will be appended automatically) userlogin
? Your full name? dalongrong
? Your email address? 1141591465@qq.com
? Your organization or username? (used to tag docker images) dalongrong
? Host the service runs on?
? Port the service runs on? 0
? What does this service do?
? Does this service need auth? No
? Is this a hydra-express service? Yes
? Set up a view engine? No
? Set up logging? No
? Enable CORS on serverResponses? Yes
? Run npm install? No
create userlogin-service/specs/test.js
create userlogin-service/specs/helpers/chai.js
create userlogin-service/.editorconfig
create userlogin-service/.eslintrc
create userlogin-service/.gitattributes
create userlogin-service/.nvmrc
create userlogin-service/.gitignore
create userlogin-service/package.json
create userlogin-service/README.md
create userlogin-service/userlogin-service.js
create userlogin-service/config/sample-config.json
create userlogin-service/config/config.json
create userlogin-service/scripts/docker.js
create userlogin-service/routes/userlogin-v1-routes.js
Done!
'cd userlogin-service' then 'npm install' and 'npm start'
启动&&服务访问
- 启动
yarn run start
node userlogin-service.js
INFO
{ event: 'start',
message: 'userlogin-service (v.0.0.1) server listening on port 28418' }
INFO
{ event: 'info', message: 'Using environment: development' }
serviceInfo { serviceName: 'userlogin-service',
serviceIP: '10.6.204.19',
servicePort: 28418 }
- 访问

- redis 服务注册信息

集成docker
- build

使用hydra-cli 查看信息
- 配置redis
hydra-cli config dalong
redisUrl: 127.0.0.1
redisPort: 6379
redisDb: 15
- 选择instance
hydra-cli use dalong
- 查看nodes

- 更多支持的命令
hydra-cli
hydra-cli version 1.5.5
Usage: hydra-cli command [parameters]
See docs at: https://github.com/flywheelsports/hydra-cli
A command line interface for Hydra services
Commands:
help - this help list
cfg list serviceName - display a list of config versions
cfg pull label - download configuration file
cfg push label filename - update configuration file
cfg remove label - remove a configuration version
config instanceName - configure connection to redis
config list - display current configuration
use instanceName - name of redis instance to use
health [serviceName] - display service health
healthlog serviceName - display service health log
message create - create a message object
message send message.json - send a message
nodes [serviceName] - display service instance nodes
redis info - display redis info
refresh node list - refresh list of nodes
rest path [payload.json] - make an HTTP RESTful call to a service
routes [serviceName] - display service API routes
services [serviceName] - display list of services
shell - display command to open redis shell
说明
meduim 上有一个详细介绍实现细节的文章
https://medium.com/hydramicroservices/building-light-weight-microservices-using-redis-dc5b3bca741
参考资料
https://medium.com/hydramicroservices/building-light-weight-microservices-using-redis-dc5b3bca741
hydra nodejs 微服务框架简单试用的更多相关文章
- 基于.NET CORE微服务框架 -surging的介绍和简单示例 (开源)
一.前言 至今为止编程开发已经11个年头,从 VB6.0,ASP时代到ASP.NET再到MVC, 从中见证了.NET技术发展,从无畏无知的懵懂少年,到现在的中年大叔,从中的酸甜苦辣也只有本人自知.随着 ...
- 简单Spring Cloud 微服务框架搭建
微服务是现在比较流行的技术,对于程序猿而言,了解并搭建一个基本的微服务框架是很有必要滴. 微服务包含的内容非常多,一般小伙伴们可以根据自己的需求不断添加各种组件.框架. 一般情况下,基本的微服务框架包 ...
- 非常完善的两个微服务框架比较(SpringCloud与Dubbo)
微服务架构是互联网很热门的话题,是互联网技术发展的必然结果.它提倡将单一应用程序划分成一组小的服务,服务之间互相协调.互相配合,为用户提供最终价值. 虽然微服务架构没有公认的技术标准和规范或者草案,但 ...
- 【微服务】使用spring cloud搭建微服务框架,整理学习资料
写在前面 使用spring cloud搭建微服务框架,是我最近最主要的工作之一,一开始我使用bubbo加zookeeper制作了一个基于dubbo的微服务框架,然后被架构师否了,架构师曰:此物过时.随 ...
- AG-Admin微服务框架入门
AG-Admin微服务框架入门 @qq群:一群: 837736451 二群 169824183 一 概要介绍 AG-Admin后台地址:https://gitee.com/minull/ace-s ...
- go微服务框架kratos学习笔记九(kratos 全链路追踪 zipkin)
目录 go微服务框架kratos学习笔记九(kratos 全链路追踪 zipkin) zipkin使用demo 数据持久化 go微服务框架kratos学习笔记九(kratos 全链路追踪 zipkin ...
- 基于.NET CORE微服务框架 -谈谈surging API网关
1.前言 对于最近surging更新的API 网关大家也有所关注,也收到了不少反馈提出是否能介绍下Api网关,那么我们将在此篇文章中剥析下surging的Api 网关 开源地址:https://git ...
- 基于.NET CORE微服务框架 -浅析如何使用surging
1.前言 surging受到大家这么强烈的关注,我感到非常意外,比如有同僚在公司的分享会上分享surging, 还有在博客拿其它的RPC框架,微服务做对比等等,这些举动都让我感觉压力很大,毕竟作为个人 ...
- MicroService.Core简易微服务框架《一、简介》
MicroService.Core MicroService.Core 的初衷是为了方便的创建一个微服务, 可作为 Windows Service 或者控制台模式启动. 它底层使用了 OWin 自托管 ...
随机推荐
- Codeforces Round #523 (Div. 2) Solution
A. Coins Water. #include <bits/stdc++.h> using namespace std; int n, s; int main() { while (sc ...
- poj1106 Transmitters
地址:http://poj.org/problem?id=1106 题目: Transmitters Time Limit: 1000MS Memory Limit: 10000K Total S ...
- Eclipse自动提示
在java的自动激活触发器里输入:abcdefghijklmnopqrstuvwxyz.
- IntelliJ idea的初次使用
1. 首次使用Idea工具,需要安装.我安装的版本是14.0.2.安装包下载地址 http://pan.baidu.com/s/1gfFkrzt 2. 安装SVN. 3.配置JDK. 4.配置mave ...
- linux内核分析第四周-使用库函数API和C代码中嵌入汇编代码两种方式使用同一个系统调用
本周作业的主要内容就是采用gcc嵌入汇编的方式调用system call.系统调用其实就是操作系统提供的服务.我们平时编写的程序,如果仅仅是数值计算,那么所有的过程都是在用户态完成的,但是我们想将变量 ...
- POJ 2195 Going Home(费用流)
http://poj.org/problem?id=2195 题意: 在一个网格地图上,有n个小人和n栋房子.在每个时间单位内,每个小人可以往水平方向或垂直方向上移动一步,走到相邻的方格中.对每个小人 ...
- redis的过期策略以及内存淘汰机制
redis采用的是定期删除+惰性删除策略. 为什么不用定时删除策略? 定时删除,用一个定时器来负责监视key,过期则自动删除.虽然内存及时释放,但是十分消耗CPU资源.在大并发请求下,CPU要将时间应 ...
- mac上将代码上传到github以及github对100M以上文件限制上传的处理(lfs)。
前言 有时我们会写一些小程序来学习新的知识,但是完事之后过一段时间可能会忘记,最好的办法就是找到原来的代码看一看.现在可以将代码免费托管到一些网站上,其中最著名的非github莫属了, 今天就把这个过 ...
- 【源码学习之spark core 1.6.1 standalone模式下的作业提交】
说明:个人原创,转载请说明出处 http://www.cnblogs.com/piaolingzxh/p/5656876.html 未完待续
- RabbitMQ入门_03_推拉模式
我们知道,消费者有两种方式从消息中间件获取消息: 推模式:消息中间件主动将消息推送给消费者 拉模式:消费者主动从消息中间件拉取消息 推模式将消息提前推送给消费者,消费者必须设置一个缓冲区缓存这些消息. ...