go-kratos/kratos
GitHub: go-kratos/kratos
Kratos 是一个功能完备的 Go 微服务治理框架,旨在帮助开发者快速构建健壮的云原生应用。
Stars: 25495 | Forks: 4156
##### 翻译为:[简体中文](README_zh.md)
## 关于 Kratos
Kratos 是一个用 golang 实现的面向微服务的治理框架,它提供了便捷的能力来帮助你从零开始快速构建一个健壮的应用程序,例如:
- [通信协议](https://go-kratos.dev/docs/component/api) 通过 Protobuf 定义,基于 HTTP/gRPC。
- 抽象的 [transport](https://go-kratos.dev/docs/component/transport/overview) 层支持:[HTTP](https://go-kratos.dev/docs/component/transport/http) / [gRPC](https://go-kratos.dev/docs/component/transport/grpc)。
- 强大的 [middleware](https://go-kratos.dev/docs/component/middleware/overview) 设计,支持:[Tracing (OpenTelemetry)](https://go-kratos.dev/docs/component/middleware/tracing)、[Metrics (默认为 Prometheus)](https://go-kratos.dev/docs/component/middleware/metrics)、[Recovery](https://go-kratos.dev/docs/component/middleware/recovery) 等。
- [Registry](https://go-kratos.dev/docs/component/registry) 接口可以通过插件连接到各种其他集中式注册中心。
- [标准日志接口](https://go-kratos.dev/docs/component/log) 简化了第三方日志库的集成,并可通过 *Fluentd* 收集日志。
- 自动支持通过 Accept 和 Content-Type 选择内容 [encoding](https://go-kratos.dev/docs/component/encoding)。
- [configurations](https://go-kratos.dev/docs/component/config) 和动态配置支持多种数据源(使用原子操作)。
- 在 HTTP/gRPC 协议中,使用统一的 [metadata](https://go-kratos.dev/docs/component/metadata) 传输方式。
- 你可以在 proto 中定义 [errors](https://go-kratos.dev/docs/component/errors/),并使用 protoc-gen-go 生成枚举。
- 你可以在 HTTP/gRPC 服务支持的 Protobuf 中定义 [验证规则](https://go-kratos.dev/docs/component/middleware/validate)。
- 自动生成 [Swagger API](https://go-kratos.dev/docs/guide/openapi),并通过添加 [Swagger plugin](https://github.com/go-kratos/swagger-api) 启动内嵌的 Swagger UI endpoint。
Kratos 易于上手,功能强大,并提供了大型、健壮应用所需的工具。
## 学习 Kratos
Kratos 拥有所有现代 Web 应用框架中最详尽、最彻底的[文档](https://go-kratos.dev/docs/getting-started/start)和[示例](https://github.com/go-kratos/examples)库,让你轻松上手该框架。
我们还提供了一个[现代化模板](https://github.com/go-kratos/kratos-layout)。该模板应有助于减少搭建现代项目所需的工作量。
### 目标
Kratos 旨在提升你的生产力。通过整合优秀的资源并提供进一步支持,程序员可以摆脱在分布式系统和软件工程领域可能遇到的大多数问题,从而专注于业务发布。此外,对于每位程序员来说,Kratos 也是一个理想的微服务学习仓库,涵盖了许多方面,有助于丰富他们的经验和技能。
### 原则
* **简单**:适当的设计,代码 Plain 且易懂。
* **通用**:涵盖业务开发的各种实用工具。
* **高效**:加快业务升级的效率。
* **稳定**:在生产环境中验证过的基础库具有高可测试性、高覆盖率以及高安全性和可靠性的特点。
* **健壮**:通过高质量的基础库消除误用。
* **高性能**:在排除 *unsafe* 情况下的 hacking 优化的前提下,实现最优性能。
* **可扩展性**:设计合理的接口,你可以扩展基础库等实用工具以满足进一步的需求。
* **容错性**:为应对失败而设计,加强在 Kratos 中对 SRE 的理解和实践,以实现更强的鲁棒性。
* **工具链**:包含丰富的工具链,例如 cache 的代码生成、lint 工具等。
## 快速开始
通过 [docker](https://www.docker.com/products/docker-desktop) 创建一个 kratos 运行环境:
```
docker run -it --rm -p 8000:8000 --workdir /workspace golang
```
```
apt-get update && apt-get -y install protobuf-compiler
export GOPROXY=https://goproxy.io,direct
go install github.com/go-kratos/kratos/cmd/kratos/v2@latest && kratos upgrade
```
```
kratos new helloworld
cd helloworld/ && go mod tidy
kratos run
```
使用浏览器打开并访问:`http://localhost:8000/helloworld/kratos`,Kratos 程序正在运行!
如果你需要更多信息,请访问 kratos [文档](https://go-kratos.dev/docs/getting-started/start)。
## 安全漏洞
如果你在 Kratos 中发现安全漏洞,请发送电子邮件至 go-kratos@googlegroups.com 联系 tonybase。所有安全漏洞将得到及时处理。
## 许可证
Kratos 框架是根据 [MIT license](./LICENSE) 许可的开源软件。
## 致谢
以下项目对 Kratos 的设计有特别影响。
- [go-kit/kit](https://github.com/go-kit/kit) 是一个用于在 go 中构建微服务的编程工具包。
- [asim/go-micro](https://github.com/asim/go-micro) 一个分布式系统开发框架。
- [google/go-cloud](https://github.com/google/go-cloud) 是 go cloud 开发工具包。
- [zeromicro/go-zero](https://github.com/zeromicro/go-zero) 是一个包含许多内置工程实践的 web 和 rpc 框架。
- [beego/beego](https://github.com/beego/beego) 是一个包含 RESTful APIs、web apps 和 backend services 的 web 框架。
标签:API网关, DNS解析, EVTX分析, Go语言, gRPC, Kratos, Protobuf, Python工具, RPC框架, 中间件, 分布式系统, 后端开发, 响应大小分析, 开源项目, 微服务框架, 日志审计, 服务发现, 服务器, 服务治理, 架构, 模块化设计, 熔断降级, 用户代理, 程序破解, 自动化修复, 自定义请求头, 请求拦截, 负载均衡, 高并发
