go高性能微服务框架 --- api, rpc, websocket, mqc, cron一体化框架

weixin_38050048 2019-09-20 10:44:33
# hydra

[https://github.com/micro-plat/hydra](https://github.com/micro-plat/hydra)



hydra 是基于 go 语言和众多开源项目实现的分布式微服务框架

hydra['haɪdrə]致力于提供统一的,丰富功能的后端开发框架,降低后端开发的复杂性,提高开发效率。目前已支持的服务类型有:`http api`服务,`rpc`服务,`websocket`服务,`mqc`消息消费服务,`cron`定时任务服务,`web`服务,静态文件服务。

特性

- 一体化框架, 支持 6+服务器类型
- 微服务的基础设施, 服务注册发现,熔断降级,集成监控与统一配置管理
- 多集群模式支持,对等,主备,分片等
- 丰富的后端库支持 redis,memcache,activieMQ,mqtt,influxdb,mysql,oracle,elasticsearch,jwt 等等
- 跨平台支持(linux,macOS 10.9+,windows 7+)
- 20+线上项目实践经验
- 全 golang 原生实现

## github

[https://github.com/micro-plat/hydra](https://github.com/micro-plat/hydra)



### 示例

1. 编写代码

新建文件夹`hello`,并添加`main.go`文件,输入以下代码:

```go
package main

import (
"github.com/micro-plat/hydra/context"
"github.com/micro-plat/hydra/component"
"github.com/micro-plat/hydra/hydra"
)

func main() {
app := hydra.NewApp(
hydra.WithPlatName("myplat"), //平台名称
hydra.WithSystemName("demo"), //系统名称
hydra.WithClusterName("test"), //集群名称
hydra.WithServerTypes("api"), //服务器类型为http api
hydra.WithRegistry("fs://../"), //使用本地文件系统作为注册中心
hydra.WithDebug())

app.API("/hello",hello)
app.Start()
}

func hello(ctx *context.Context) (r interface{}) {
return "hello world"
}
```
2. 编译生成服务

```go
go install hello
```
3. 安装本地服务和生成注册中心配置

```go
hello install
```
4. 运行服务

```go
./hello run
```

5. 测试服务

```go
curl http://localhost:8090/hello

{"data":"hello world"}
```



[hydra 微服务开发入门](https://github.com/micro-plat/hydra/tree/master/docs/getting-started_00.md)

[hydra 微服务开发规范](https://github.com/micro-plat/hydra/tree/master/docs/getting-started_01.md)

[构建 API 服务一](https://github.com/micro-plat/hydra/tree/master/docs/getting-started_api_01.md)

[构建 API 服务二](https://github.com/micro-plat/hydra/tree/master/docs/getting-started_api_02.md)

[构建消息消费服务(MQC)](https://github.com/micro-plat/hydra/tree/master/docs/getting-started_mqc_01.md)

[构建任务调度服务(CRON)](https://github.com/micro-plat/hydra/tree/master/docs/getting-started_cron_01.md)

[构建远程调用服务(RPC)](https://github.com/micro-plat/hydra/tree/master/docs/getting-started_rpc_01.md)

[构建静态文件服务](https://github.com/micro-plat/hydra/tree/master/docs/getting-started_static_01.md)

[构建 websocket 服务(WS)](https://github.com/micro-plat/hydra/tree/master/docs/getting-started_ws_01.md)

[性能指标收集(metric)](https://github.com/micro-plat/hydra/tree/master/docs/getting-started_metric_01.md)

[日志配置与管理](https://github.com/micro-plat/hydra/tree/master/docs/getting-started_log_01.md)


[https://github.com/micro-plat/hydra](https://github.com/micro-plat/hydra)
...全文
156 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
weixin_38123446 2019-09-20
  • 打赏
  • 举报
回复
欢迎关注
weixin_38125509 2019-09-20
  • 打赏
  • 举报
回复
学习。。。
weixin_38125855 2019-09-20
  • 打赏
  • 举报
回复
支持!!
weixin_38127299 2019-09-20
  • 打赏
  • 举报
回复
学习了...
weixin_38127863 2019-09-20
  • 打赏
  • 举报
回复
感谢关注
weixin_38060626 2019-09-20
  • 打赏
  • 举报
回复
支持docker部署
weixin_38063296 2019-09-20
  • 打赏
  • 举报
回复
提供gaea项目结构生成工具
weixin_38072900 2019-09-20
  • 打赏
  • 举报
回复
[hydra开发定时任务](https://github.com/micro-plat/hydra/blob/master/docs/getting-started_cron_01.md) 任务配置支持zookeeper和程序创建
weixin_38075910 2019-09-20
  • 打赏
  • 举报
回复
不错
weixin_38108228 2019-09-20
  • 打赏
  • 举报
回复
感谢关注
weixin_38113164 2019-09-20
  • 打赏
  • 举报
回复

433

社区成员

发帖
与我相关
我的任务
社区描述
其他技术讨论专区
其他 技术论坛(原bbs)
社区管理员
  • 其他技术讨论专区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧