{"id":50432862,"url":"https://github.com/daidai21/biz_ext_framework","last_synced_at":"2026-05-31T15:01:55.113Z","repository":{"id":350256024,"uuid":"1203915734","full_name":"daidai21/biz_ext_framework","owner":"daidai21","description":"a business extension module framework, created by CodeX","archived":false,"fork":false,"pushed_at":"2026-05-27T07:50:53.000Z","size":268,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-27T09:24:24.997Z","etag":null,"topics":["architecture","bpmn","dag","ddd","vibe-coding"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/daidai21.png","metadata":{"files":{"readme":"README-ZH.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-07T14:05:58.000Z","updated_at":"2026-05-27T07:50:57.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/daidai21/biz_ext_framework","commit_stats":null,"previous_names":["daidai21/biz_ext_framework"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/daidai21/biz_ext_framework","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daidai21%2Fbiz_ext_framework","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daidai21%2Fbiz_ext_framework/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daidai21%2Fbiz_ext_framework/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daidai21%2Fbiz_ext_framework/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daidai21","download_url":"https://codeload.github.com/daidai21/biz_ext_framework/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daidai21%2Fbiz_ext_framework/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33735663,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-31T02:00:06.040Z","response_time":95,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["architecture","bpmn","dag","ddd","vibe-coding"],"created_at":"2026-05-31T15:01:54.289Z","updated_at":"2026-05-31T15:01:55.107Z","avatar_url":"https://github.com/daidai21.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# biz_ext_framework\n\n[![Read the Docs](https://img.shields.io/badge/Read%20the%20Docs-README-8CA1AF?logo=readthedocs\u0026logoColor=white)](./README.md)\n[![Coverage](https://img.shields.io/badge/Coverage-94.2%25-brightgreen)](./unittest_coverage.md)\n![Language](https://img.shields.io/badge/Language-Go-00ADD8?logo=go\u0026logoColor=white)\n![Visitors](https://visitor-badge.laobi.icu/badge?page_id=daidai21.biz_ext_framework\u0026left_text=visitors)\n![CLI Tools](https://img.shields.io/badge/CLI%20Tools-tools-6A5ACD)\n\n![Platform Components](https://img.shields.io/badge/Platform%20Components-biz__xxx-4C8EDA)\n![Extension Components](https://img.shields.io/badge/Extension%20Components-ext__xxx-F28C28)\n![Service Integration](https://img.shields.io/badge/Service%20Integration-service__manager-2E8B57)\n\n`biz_ext_framework` 是一个沉淀平台组件、扩展组件和服务侧集成能力的仓库。\n\n仓库以多个小型 Go module 组织。你可以单独使用某个模块，也可以使用 `service_manager` 作为集成层，把多个模块组合到同一个服务运行时里。\n\n## 1. 亮点\n\n- 支持 `GlobalScope` / `SessionScope` 的 IOC 业务组件容器\n- 业务 session 上下文与业务身份抽象\n- 轻量日志 / 指标 / 链路观测工具\n- FSM、BPMN-like、DAG 三类流程编排\n- SPI、流程模板、拦截器等扩展模板\n- 面向流程图生成和运行时打点解析的 CLI 工具\n\n## 2. 架构\n\n当前 `service_manager` 已集成平台组件与扩展组件：\n\n- `biz_component`\n- `biz_ctx`\n- `biz_identity`\n- `biz_observation`\n- `biz_process`\n- `ext_interceptor`\n- `ext_model`\n- `ext_process`\n- `ext_spi`\n\n这些模块都可以独立使用，`service_manager` 负责在服务侧把它们统一串起来。\n\n```text\n                          +-------------------+\n                          |  service_manager  |\n                          |     集成管理层     |\n                          +-------------------+\n                           /                 \\\n                          v                   v\n               +-------------------+   +-------------------+\n               |   biz_xxx modules  |   |   ext_xxx modules  |\n               |     平台组件        |   |      扩展组件       |\n               +-------------------+   +-------------------+\n               | biz_component     |   | ext_model         |\n               | biz_ctx           |   | ext_process       |\n               | biz_identity      |   | ext_spi           |\n               | biz_observation   |   | ext_interceptor   |\n               | biz_process       |   |                   |\n               +-------------------+   +-------------------+\n```\n\n## 3. 模块\n\n### 3.1 平台组件\n\n#### 3.1.1 `biz_component`\n\nIOC 风格平台组件容器。\n\n核心能力：\n\n- `Container`\n- `GlobalScope`\n- `SessionScope`\n- 泛型 `Key[T]` / `Provider[T]`\n- 同一个组件名可同时存在 `Global` 与 `Session` 两个作用域\n\n文档：\n\n- English: [`biz_component/README.md`](./biz_component/README.md)\n- 中文: [`biz_component/README-ZH.md`](./biz_component/README-ZH.md)\n\n#### 3.1.2 `biz_process`\n\n平台侧流程编排能力。\n\n核心能力：\n\n- FSM\n- BPMN-like 串行层 / 并行节点编排\n- DAG 编排\n- 通过 `ProcessStringer` 提供标准化 JSON 序列化\n- 流程图生成与运行时打点解析工具\n\n文档：\n\n- English: [`biz_process/README.md`](./biz_process/README.md)\n- 中文: [`biz_process/README-ZH.md`](./biz_process/README-ZH.md)\n\n#### 3.1.3 `biz_ctx`\n\n平台侧业务 session 上下文组件。\n\n核心能力：\n\n- `BizSession`\n- `BizSessionId`\n- `WithBizSession` / `BizSessionFromContext`\n- 在请求上下文中透传和读取业务 session\n\n文档：\n\n- English: [`biz_ctx/README.md`](./biz_ctx/README.md)\n- 中文: [`biz_ctx/README-ZH.md`](./biz_ctx/README-ZH.md)\n\n#### 3.1.4 `biz_identity`\n\n平台侧业务身份抽象组件。\n\n核心能力：\n\n- `BizIdentity`\n- `ParseIdentityID`\n- `ValidateIdentityID`\n- `Parser` / `Validator`\n\n文档：\n\n- English: [`biz_identity/README.md`](./biz_identity/README.md)\n- 中文: [`biz_identity/README-ZH.md`](./biz_identity/README-ZH.md)\n\n#### 3.1.5 `biz_observation`\n\n平台侧观测组件。\n\n核心能力：\n\n- `Logger`\n- `MetricsRecorder`\n- `Tracer`\n- 日志、指标、链路的统一抽象和 helper\n\n文档：\n\n- English: [`biz_observation/README.md`](./biz_observation/README.md)\n- 中文: [`biz_observation/README-ZH.md`](./biz_observation/README-ZH.md)\n\n### 3.2 扩展组件\n\n#### 3.2.1 `ext_model`\n\n扩展侧模型容器组件。\n\n核心能力：\n\n- `ExtObj`\n- `ExtModel`\n- `ExtMap`\n- `CopyExtMap` 及其过滤 / 深拷贝选项\n\n文档：\n\n- English: [`ext_model/README.md`](./ext_model/README.md)\n- 中文: [`ext_model/README-ZH.md`](./ext_model/README-ZH.md)\n\n#### 3.2.2 `ext_process`\n\n扩展侧流程模板组件。\n\n核心能力：\n\n- `Template`\n- `Mode`（`Serial` / `Parallel`）\n- `DefinitionAction`\n- 扩展实现的匹配、合并和执行编排\n\n文档：\n\n- English: [`ext_process/README.md`](./ext_process/README.md)\n- 中文: [`ext_process/README-ZH.md`](./ext_process/README-ZH.md)\n\n#### 3.2.3 `ext_spi`\n\n扩展侧 SPI 模板组件。\n\n核心能力：\n\n- `Template`\n- `Mode`（`First` / `All` / `FirstMatched` / `AllMatched`）\n- `MatchFunc`\n- SPI 实现的匹配和执行模板\n\n文档：\n\n- English: [`ext_spi/README.md`](./ext_spi/README.md)\n- 中文: [`ext_spi/README-ZH.md`](./ext_spi/README-ZH.md)\n\n#### 3.2.4 `ext_interceptor`\n\n扩展侧拦截器模板组件。\n\n核心能力：\n\n- `Handler`\n- `Template`\n- `MatchFunc`\n- 拦截器链的匹配和执行编排\n\n文档：\n\n- English: [`ext_interceptor/README.md`](./ext_interceptor/README.md)\n- 中文: [`ext_interceptor/README-ZH.md`](./ext_interceptor/README-ZH.md)\n\n### 3.3 集成层\n\n#### 3.3.1 `service_manager`\n\n服务侧集成层，负责容器初始化、生命周期管理、观测依赖注入、流程编排、SPI 注册和模型过滤。\n\n文档：\n\n- English: [`service_manager/README.md`](./service_manager/README.md)\n- 中文: [`service_manager/README-ZH.md`](./service_manager/README-ZH.md)\n\n## 4. Tools\n\n仓库在 [`tools/`](./tools/README.md) 下提供了 CLI 工具：\n\n- `gen_process_graph`：从 BPMN、DAG、FSM 规格生成 Mermaid / DOT\n- `parse_process_graph`：从运行时打点日志解析 BPMN、DAG、FSM 图，并聚合指标\n\n支持从 GitHub 直接安装：\n\n```bash\ngo install github.com/daidai21/biz_ext_framework/tools/gen_process_graph@latest\ngo install github.com/daidai21/biz_ext_framework/tools/parse_process_graph@latest\n```\n\n## 5. 快速开始\n\n推荐从 `service_manager` 开始，把平台组件和扩展组件统一接入到一个服务运行时里：\n\n先安装依赖：\n\n```bash\ngo get github.com/daidai21/biz_ext_framework/service_manager\ngo get github.com/daidai21/biz_ext_framework/biz_process\n```\n\n```go\npackage main\n\nimport (\n    \"context\"\n    \"fmt\"\n\n    \"github.com/daidai21/biz_ext_framework/biz_process\"\n    \"github.com/daidai21/biz_ext_framework/service_manager\"\n)\n\nfunc main() {\n    manager, err := service_manager.NewServiceManagerBuilder(\"order-service\").\n        WithIdentityScopes(\"SELLER.SHOP\").\n        WithProcess(\"order_flow\", biz_process.Process{\n            Layers: []biz_process.ProcessLayer{\n                {\n                    Name: \"prepare\",\n                    Nodes: []biz_process.ProcessNode{\n                        biz_process.Task{\n                            Name: \"prepare\",\n                            Task: func(ctx context.Context) error {\n                                fmt.Println(\"prepare order\")\n                                return nil\n                            },\n                        },\n                    },\n                },\n            },\n        }).\n        Build()\n    if err != nil {\n        panic(err)\n    }\n\n    ctx := context.Background()\n    if err := manager.Start(ctx); err != nil {\n        panic(err)\n    }\n    defer manager.Stop(ctx)\n\n    fmt.Println(manager.IdentityContainer().IsAllowed(\"SELLER.SHOP.OPERATOR\"))\n    fmt.Println(manager.ProcessContainer().Run(ctx, \"order_flow\"))\n}\n```\n\n如果只想单独使用某个模块，直接看对应子目录下的 README 即可。\n\n工具使用：\n\n```bash\ngen_process_graph -type bpmn -input process.json\nparse_process_graph -type fsm -input fsm_metrics.jsonl -metrics qps,success_rate,p99\n```\n\n## 6. 仓库结构\n\n- `biz_component/`\n- `biz_ctx/`\n- `biz_identity/`\n- `biz_observation/`\n- `biz_process/`\n- `ext_interceptor/`\n- `ext_model/`\n- `ext_process/`\n- `ext_spi/`\n- `service_manager/`\n- `tools/`\n- `Makefile`\n- `go.mod`\n\n## 7. 开发\n\n在目标模块目录下运行测试：\n\n```bash\ncd biz_process \u0026\u0026 go test ./...\n```\n\n常用仓库级命令：\n\n```bash\nmake statistics_lines\nmake unittest\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaidai21%2Fbiz_ext_framework","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaidai21%2Fbiz_ext_framework","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaidai21%2Fbiz_ext_framework/lists"}