CI / CI (push) Successful in 3m7s
**Root cause:** ServiceAdapter dispatcher sets X-Upstream-Path to template strings like `/v1/poimen/executions/{id}/stream` with literal `{id}`. The handler extracted `{id}` as the workflow ID instead of the actual value.
**Fix:** All handlers read `workflow_id` from query params (`?workflow_id=xxx`). Paths changed to flat resource names without path parameters.
**API contract:**
```
GET /executions — list
GET /executions/detail?workflow_id=xxx — describe
GET /executions/history?workflow_id=xxx — history
GET /executions/stream?workflow_id=xxx — SSE
POST /executions/signal?workflow_id=xxx — signal
DELETE /executions/detail?workflow_id=xxx — terminate
```
All accessed via `X-Service: poimen` + `X-Resource: <name>` headers.
---------
Reviewed-on: #42
101 lines
2.6 KiB
Go
101 lines
2.6 KiB
Go
package serviceadapter
|
|
|
|
import (
|
|
"forgejo.riotpiao.com/rock/homelab-frontend/internal/temporal"
|
|
)
|
|
|
|
// NewPoimenAdapter creates a ServiceAdapter for the Poimen orchestrator service.
|
|
func NewPoimenAdapter(h *temporal.Handler) *ServiceAdapter {
|
|
return &ServiceAdapter{
|
|
Namespace: "poimen",
|
|
ServiceName: "poimen",
|
|
Handler: temporal.NewPoimenHandler(h),
|
|
Spec: *GetPoimenSpec(),
|
|
}
|
|
}
|
|
|
|
// GetPoimenSpec returns the ServiceAdapter spec for the Poimen service.
|
|
func GetPoimenSpec() *Spec {
|
|
return &Spec{
|
|
ServiceName: "poimen",
|
|
Upstream: Upstream{
|
|
URL: "internal://poimen",
|
|
TimeoutSeconds: 60,
|
|
},
|
|
Auth: Auth{
|
|
Required: true,
|
|
Capability: "workflow:read",
|
|
},
|
|
Resources: []Resource{
|
|
{
|
|
Name: "plan",
|
|
Methods: []Method{{
|
|
Verb: "POST",
|
|
UpstreamPath: "/v1/poimen/plan",
|
|
Auth: &Auth{Required: true, Capability: "workflow:execute"},
|
|
}},
|
|
},
|
|
{
|
|
Name: "execute",
|
|
Methods: []Method{{
|
|
Verb: "POST",
|
|
UpstreamPath: "/v1/poimen/execute",
|
|
Auth: &Auth{Required: true, Capability: "workflow:execute"},
|
|
}},
|
|
},
|
|
{
|
|
Name: "executions",
|
|
Methods: []Method{
|
|
{
|
|
Verb: "GET",
|
|
UpstreamPath: "/v1/poimen/executions",
|
|
Auth: &Auth{Required: true, Capability: "workflow:read"},
|
|
},
|
|
},
|
|
},
|
|
// Note: workflow_id is passed as ?workflow_id=xxx query param,
|
|
// not as a path segment. The ServiceAdapter dispatcher does not
|
|
// substitute path parameters.
|
|
{
|
|
Name: "execution-detail",
|
|
Methods: []Method{
|
|
{
|
|
Verb: "GET",
|
|
UpstreamPath: "/v1/poimen/executions/detail",
|
|
Auth: &Auth{Required: true, Capability: "workflow:read"},
|
|
},
|
|
{
|
|
Verb: "DELETE",
|
|
UpstreamPath: "/v1/poimen/executions/detail",
|
|
Auth: &Auth{Required: true, Capability: "workflow:execute"},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
Name: "execution-history",
|
|
Methods: []Method{{
|
|
Verb: "GET",
|
|
UpstreamPath: "/v1/poimen/executions/history",
|
|
Auth: &Auth{Required: true, Capability: "workflow:read"},
|
|
}},
|
|
},
|
|
{
|
|
Name: "execution-stream",
|
|
Methods: []Method{{
|
|
Verb: "GET",
|
|
UpstreamPath: "/v1/poimen/executions/stream",
|
|
Auth: &Auth{Required: true, Capability: "workflow:read"},
|
|
}},
|
|
},
|
|
{
|
|
Name: "execution-signal",
|
|
Methods: []Method{{
|
|
Verb: "POST",
|
|
UpstreamPath: "/v1/poimen/executions/signal",
|
|
Auth: &Auth{Required: true, Capability: "workflow:execute"},
|
|
}},
|
|
},
|
|
},
|
|
}
|
|
}
|