sponge is a microservice framework, a tool for quickly creating microservice code. sponge has a rich generating code commands, a total of 12 different functional code, these functional code can be combined into a complete service (similar to artificially broken sponge cells can be automatically reorganized into a new sponge ). Microservice code features include logging, service registration and discovery, registry, rate limit, circuit breaker, trace, metrics monitoring, pprof performance analysis, statistics, caching, CICD. The code uses a decoupled layered structure and it's easy to add or replace functional code. As an efficiency-enhancing tool, commonly repeated code is basically generated automatically and only business logic code needs to be populated based on the generated template code examples.
The generated code is based on three approaches Yaml, SQL DDL and Protocol buffers, each possessing different functional code generation, and the framework diagram of the generated code is shown in Figure 1-1.
Figure 1-1 spong generation code framework diagram
In the same folder, if the latest generated code is found to conflict with the original code, sponge will cancel the generation process and will not make any changes to the original code, so you don't have to worry about writing business logic code that is overwritten.
The microservice code framework created by sponge is shown in Figure 1-2, which is a typical microservice hierarchy containing common service governance functions.
Figure 1-2 Microservices framework diagram
Microservices main functions:
The code directory structure follows project-layout, and the code directory structure is shown below.
.
├── api # proto files and the generated *pb.go directory
├── assets # Directory of other assets used with the repository (images, logos, etc.)
├── build # Package and continuous integration directory
├── cmd # Program entry directory
├── configs # Directory for configuration files
├── deployments # Configuration and template directories for IaaS, PaaS, system and container orchestrated deployments
├─ docs # Design documentation and interface documentation directory
├── internal # The code directory for private applications and libraries
│ ├── cache # business wrapper based cache directory
│ ├── config # The configuration file directory for the Go structure
│ ├── dao # Data access directory
│ ├── ecode # Custom business error code directory
│ ├── handler # http's business function implementation directory
│ ├── model # Database model directory
│ ├── routers # http routing directory
│ ├── rpcclient # The client directory to connect to the rpc service
│ ├── server # Service entry, including http, rpc, etc.
│ ├── service # rpc's business function implementation directory
│ └── types # Directory of request and response types for http
├── pkg # The directory of libraries that external applications can use
├── scripts # A directory of scripts for performing various build, installation, analysis, etc. operations
├── test # Additional external test procedures and test data
└── third_party # External helpers, forked code, and other third-party tools
The web service and rpc service directory structures are basically the same, with some directories unique to the web service (routers, handlers, types in the internal directory) and some directories unique to the rpc service (services in the internal directory).
If it's useful to you, give it a star ⭐.
See the LICENSE file for licensing information.