
Sponge是一个有力的Go开发框架。它的核心概念通过解析JSON , SQL或Protobuf文件围绕反向工程模块化代码。生成的代码可以灵活,无缝地组装到各种类型的完整后端服务中(类似于海绵细胞的特征,在该服务的特征上,拆卸的海绵细胞可以自动重组为新的海绵)。 Sponge为项目开发提供了多合一的解决方案,涵盖代码生成,开发,测试,API文档和部署,可显着提高发展效率,降低复杂性,并通过“低代码方法”启用高质量的项目。
海绵适合快速开发各种高性能后端服务,包括但不限于:
Web服务(GIN);gRPC服务;HTTP+gRPC混合动力服务;gRPC Gateway API服务。此外,开发人员可以使用自定义模板生成各种类型的代码以满足特定的业务需求。
单击一代完整的后端服务代码
对于仅需要CRUD APIs Web或gRPC服务,不需要编写Go代码。只需将数据库(例如MySQL , MongoDB , PostgreSQL , SQLite )连接到一键生成完整的后端服务代码,然后轻松地将其部署到Linux服务器,Docker或Kubernetes。
有效开发通用服务
在开发通用Web , gRPC , HTTP+gRPC或gRPC Gateway服务时,您只需要专注于三个方面:
Sponge自动生成框架代码和CRUD API代码。
支持自定义模板,提供灵活的可扩展性
Sponge支持使用自定义模板生成各种类型的项目特定代码,而不仅限于Go语言。例如:
安装海绵
Sponge支持在Windows,MacOS和Linux上安装。单击以查看海绵安装指南。
打开代码生成UI
安装后,运行以下命令以打开海绵UI:
sponge run访问http://localhost:24631在本地浏览器中以通过UI接口生成代码,如下所示:
要从其他主机上的浏览器访问,请在启动UI时指定主机IP或域,例如,
sponge run -a http://your_host_ip:24631。另外,您可以在Docker中运行UI服务以支持交叉主机访问。单击以查看在Docker中运行海绵UI服务的指南。
Sponge支持使用内置模板和自定义模板生成代码,如下图所示。
Sponge支持创建六种基于微服务体系结构的六种类型的后端服务。下图说明了典型的分层微服务结构,具有高性能,可扩展性和内置服务治理功能。
由Microservices框架创建的HTTP和GRPC服务代码的性能测试:50并发,100万个请求。
单击以查看测试代码。
Sponge创建的项目代码目录结构遵循项目标准。
这是生成的monolithic application single repository (monolith)或microservice multi-repository (multi-repo)代码的目录结构:
.
├── api # Protobuf files and generated * pb.go directory
├── assets # Store various static resources, such as images, markdown files, etc.
├── cmd # Program entry directory
├── configs # Directory for configuration files
├── deployments # Bare metal, docker, k8s deployment script directory.
├── docs # Directory for API interface Swagger documentation.
├── internal # Directory for business logic code.
│ ├── cache # Cache directory wrapped around business logic.
│ ├── config # Directory for Go structure configuration files.
│ ├── dao # Data access directory.
│ ├── database # database directory.
│ ├── ecode # Directory for system error codes and custom business error codes.
│ ├── handler # Directory for implementing HTTP business functionality (specific to web services).
│ ├── model # Database model directory.
│ ├── routers # HTTP routing directory.
│ ├── rpcclient # Directory for client-side code that connects to grpc services.
│ ├── server # Directory for creating services, including HTTP and grpc.
│ ├── service # Directory for implementing grpc business functionality (specific to grpc services).
│ └── types # Directory for defining request and response parameter structures for HTTP.
├── pkg # Directory for shared libraries.
├── scripts # Directory for scripts.
├── test # Directory for scripts required for testing services and test SQL.
├── third_party # Directory for third-party protobuf files or external helper programs.
├── Makefile # Develop, test, deploy related command sets .
├── go.mod # Go module dependencies and version control file.
└── go.sum # Go module dependencies key and checksum file.这是生成的microservice monolithic repository (mono-repo)代码(也称为大型存储库目录结构)的目录结构:
.
├── api
│ ├── server1 # Protobuf files and generated *pb.go directory for service 1.
│ ├── server2 # Protobuf files and generated *pb.go directory for service 2.
│ ├── server3 # Protobuf files and generated *pb.go directory for service 3.
│ └── ...
├── server1 # Code directory for Service 1, it has a similar structure to the microservice multi repo directory.
├── server2 # Code directory for Service 2, it has a similar structure to the microservice multi repo directory.
├── server3 # Code directory for Service 3, it has a similar structure to the microservice multi repo directory.
├── ...
├── third_party # Third-party protobuf files.
├── go.mod # Go module dependencies and version control file.
└── go.sum # Go module dependencies' checksums and hash keys.单击以查看海绵开发项目的详细文档,包括代码生成,开发,配置和部署说明等。
如果对您有所帮助,请给它星星。