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

weixin_38050048 weixin_38050048 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
# 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)
...全文

相关推荐

Go语言云原生实战150篇完整学习路径:从入门到精通Go后端开发

160篇文章从Go的第一个到分布式系统的架构设计,覆盖了Go后端开发的完整知识体系。学习路径的核心原则是: 先学语法再学并发,先写Web再搞微服务,先跑项目再看源码。最大的经验是: 不要跳过基础。我见过太多人goroutine都写不好就去学K8s Operator,结果生产环境一个数据竞争排查三天。把基础打扎实,后面的进阶是水到渠成的事。Go的哲学是简单,但简单不代表容易。160篇的内容量不小,按自己的节奏学,每篇的代码都动手跑一遍,踩坑经验记下来,3个月后你会发现Go后端开发真的不难。

白话机器学习

外盘期货历史高频tick数据覆盖了CME、ICE、Eurex等主要交易所的主流品种,包括轻质原油、黄金、标普500指数、恒生指数、富时A50指数、欧元、英镑等期货合约 每条数据都记录了精确到毫秒的时间

外盘期货历史高频tick数据覆盖了CME、ICE、Eurex等主要交易所的主流品种,包括轻质原油、黄金、标普500指数、恒生指数、富时A50指数、欧元、英镑等期货合约。每条数据都记录了精确到毫秒的时间戳、成交价格、成交量,部分品种还提供买一价和卖一价。数据按交易日存储,完整保留了盘中每一笔成交明细,适合用于回测、微观结构分析或策略研究。 数据源:CMES金融数据库

2401_89140926

5G医学数字影像服务平台建设方案.pptx

5G医学数字影像服务平台建设方案.pptx

公众号:优享智库

仓储物流信息化管理系统建设方案共79页.pptx

仓储物流信息化管理系统建设方案共79页.pptx

公众号:优享智库

AI大模型赋能企业数字化转型总体规划与实施路径.pptx

AI大模型赋能企业数字化转型总体规划与实施路径.pptx

公众号:优享智库
评论 11
收藏 已收藏
分享
返回顶部