
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.單擊以查看海綿開發項目的詳細文檔,包括代碼生成,開發,配置和部署說明等。
如果對您有所幫助,請給它星星。