Skill站外收录 @skilllib/skill-2117939930272414917
add-microservice
提供微服务的自动化创建与初始化能力,涵盖目录结构搭建、配置文件生成、服务注册及功能提案全流程,确保新微服务符合项目规范并可立即集成到主应用中。
软件开发 AI 技能
Skills.MD
## Workflow
Copy this checklist and track your progress:
```
Creating a new microservice:
- [ ] Step 1: Create a Directory for the New Microservice
- [ ] Step 2: Create `doc.go` with Code Generation Directive
- [ ] Step 3: Generate Initial `service.yaml`
- [ ] Step 4: Fill in `service.yaml`
- [ ] Step 5: Generate Microservice File Structure
- [ ] Step 6: Add the Microservice to the Main Application
- [ ] Step 7: Propose Features
```
#### Step 1: Create a Directory for the New Microservice
Each microservice is kept in a separate directory. Create a new directory for the new microservice.
```bash
mkdir -p myservice
cd myservice
```
#### Step 2: Create `doc.go` with Code Generation Directive
Create `doc.go` with the directive to trigger the code generator.
```go
package myservice
//go:generate go run github.com/microbus-io/fabric/codegen
```
#### Step 3: Generate Initial `service.yaml`
Run `go generate` to create the initial `service.yaml` file.
**Important** Do not attempt to create `service.yaml` yourself from scratch. Always let the code generator initialize it.
#### Step 4: Fill in `service.yaml`
The `service.yaml` file is the blueprint of your microservice. Fill in the `general` section:
- The `host` defines the host name under which this microservice will be addressable. It must be unique across the application. Use reverse domain notation, e.g. `myservice.myproject.mycompany`.
- The `description` should explain what this microservice is about.
```yaml
general:
host: myservice.myproject.mycompany
description: My microservice does X, Y, and Z
```
**Important**: Do not fill in any other section of `service.yaml` unless explicitly asked to do so by the user.
#### Step 5: Generate Microservice File Structure
Run `go generate` again to generate the file structure of the microservice.
#### Step 6: Add the Microservice to the Main Application
Add the new microservice to the `app` in `main.go`, if not already added.
Note that `main.go` is typically located in the `main` directory of the project, not inside the directory of the microservice.
The order is important: add the new microservice after the core infrastructure microservices are added, and before the HTTP ingress proxy is added.
```go
func main() {
app := application.New()
// The configurator must be first
app.Add(
configurator.NewService(),
)
// Infrastructure services
app.Add(
httpegress.NewService(),
openapiportal.NewService(),
metrics.NewService(),
)
// Add your solution microservices here
app.Add(
myservice.NewService(),
)
// HTTP ingress proxy is last
app.Add(
httpingress.NewService(),
)
err := app.Run()
if err != nil {
fmt.Fprintf(os.Stderr, "%+v", err)
os.Exit(19)
}
}
```
#### Step 7: Propose Features
If you have an idea for what the microservice should include, prepare a proposal categorizing them by feature:
- Configuration properties
- Functional endpoints (RPCs)
- Outbound events
- Inbound event sinks
- Web handler endpoints
- Tickers (recurring operations)
- Metrics
Save the proposal in `AGENTS.md`, then show it to the user and seek additional instructions.
评论 0
还没有评论,来抢沙发。
相关内容
同类或同场景的收录内容
building-with-kafka-strimzi
在 Kubernetes 上构建基于 Apache Kafka 的事件驱动系统,支持高可靠的消息传递、事务性处理与精确一次语义,结合 Strimzi 运营商实现集群自动化管理,利用 Schema Registry 保障事件模式演进,适用于微服务间解耦通信与实时数据流处理场景。
站外数据与分析
609 0.0
personal-tool-builder
专注于从个人真实痛点出发快速构建实用工具,涵盖命令行程序、本地优先应用和自动化脚本的开发与演进,强调先满足自身需求再逐步扩展,通过持续自用打磨功能,避免过度设计,确保工具简洁有效且长期可维护。
站外商业与营销
196 0.0
threejs-lighting
实现三维场景中的光照与阴影控制,支持多种光源类型及环境光照明,提供从基础布光到高级阴影优化的完整方案,适用于需要真实感渲染或性能平衡的可视化项目。
站外效率工具
442 0.0
aggregation-helper
提供数据聚合场景的自动化辅助能力,涵盖 SQL 查询编写、统计分析建模、可视化方案设计及商业智能配置,支持从需求理解到生产级代码生成的全流程指导。
站外效率工具数据与分析
217 0.0
举报「add-microservice」
举报信息仅审核团队可见,同一资产 24 小时内仅可举报一次