# hydra **Repository Path**: ylmzfun_user/hydra ## Basic Information - **Project Name**: hydra - **Description**: 分布式微服务框架(用于快速开发http接口, web应用,rpc服务,websocket服务,定时任务,消息消费等) - **Primary Language**: Go - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2020-05-18 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 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 原生实现 ### 示例 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. 编译生成服务 ```sh go install hello ``` 3. 安装本地服务和生成注册中心配置 ```sh hello install ``` 4. 运行服务 ```sh ./hello run ``` 5. 测试服务 ```sh 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)