mirror of
https://gitcode.com/JianFeeeee/homeagent-sdk.git
synced 2026-10-03 07:34:23 +00:00
共享内存是内核内部实现,不对插件开发者暴露。模板不再维护任何分配 游标(历史上 bump 游标 / 模板内位图 CAS 两版都因把可变分配状态放在 共享内存里而出竞态),改为通过内核 RPC 申请/归还: - 删除 arenaWrite 本地 bump 分配器与 arenaOff/arenaUsed 全局变量 - 新增 arenaAlloc/arenaFree:走 arena.alloc / arena.free RPC - 新增 putInArena/callWithText:按 payload 大小自动选择共享槽或内联 JSON(inlinePayloadLimit=512),SDK 公开 API 仍是普通字符串/Map, 插件开发者无感 - cleaner.invoke 改为读 TextRef/内联 Text、写 RespRef/内联 Text; 插件不做任何分配(内核预分配请求槽 + 响应槽) - 同步 handshake:不再解析 arena 槽池布局(偏移与大小由 arena.alloc 的应答下发) 测试: - 新增 TestProcTemplate_UsesKernelArenaRPC:模板必须调用 arena.alloc/ arena.free,且不得再出现 arenaUsed/arenaWrite(回归保护) - TestProcTemplate_RejectsVersionMismatch 更新为 §13.1 后的「统一区域 魔数不匹配」文案 - 修正模板与 sdk/plugin.go 的 gofmt 对齐(含补上 ContextPolicy 字段)
# {{.Plg.Name}}
{{.Plg.Description}}
## Build
```bash
plugindev build
```
## Install
Upload the `.hmap` file through the Plugin Manager API:
```bash
curl -X POST http://localhost:8080/api/v1/plugins \
-H "Content-Type: application/octet-stream" \
--data-binary @dist/<name_en_snake>_linux_amd64.hmap
```
## Lifecycle
- `RegisterStopHandler` — runs on every stop (including reload/disable), before `Stop()`.
- `RegisterOnRemoveHandler` — runs **only on uninstall (remove)**, after `Stop()`; clean up the plugin's own data files here. Reload/disable do NOT trigger it. See the onRemove demo in `main.go`.