Documentation
¶
Overview ¶
Package planview embeds bide view's flow-config page in a program, with the program's plan.Registry, so the page checks a config the way plan.Load does: blocks, predicates, merges and types, as well as structure, and shows the digest a run of the flow would journal. The bide view command cannot import a program's Go types, so its -config page is structural; this package is the full check. Nothing runs, and the page is read-only.
Example ¶
A program checks a flow config against its own Registry: the type mismatch on the edge from classify to done is found only with the Registry (bide view -config checks structure only). planview.Handler serves the same check as the config page.
package main
import (
"context"
"os"
"github.com/bide-ai/bide/plan"
"github.com/bide-ai/bide/plan/planview"
)
type Order struct{ Amount int }
type Receipt struct{ Status string }
// A program checks a flow config against its own Registry: the type mismatch on the edge from
// classify to done is found only with the Registry (bide view -config checks structure only).
// planview.Handler serves the same check as the config page.
func main() {
reg := plan.NewRegistry()
_ = reg.RegisterStep("classify", func(_ context.Context, o Order) (Order, error) { return o, nil })
_ = reg.RegisterStep("done", func(_ context.Context, s string) (Receipt, error) { return Receipt{Status: s}, nil })
config := []byte(`{"version": 1, "flow": "orders",
"nodes": [{"name": "classify", "block": "classify"}, {"name": "done", "block": "done"}],
"wiring": [{"edge": ["classify", "done"]}]}`)
if planview.Check(os.Stdout, "orders.json", config, nil) {
return
}
planview.Check(os.Stdout, "orders.json", config, reg)
}
Output: orders.json:classify->done: edge "classify" -> "done" connects planview_test.Order to string (types must match exactly)
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Check ¶
Check writes the config's problems to w as "name:node: message" lines ("name:from->to: message" for an edge or arm, "name: message" for the config as a whole), warnings marked "warning:", and reports whether any is an error: the bide view -check output, with reg's checks added. See plan.InspectConfig for the problems themselves.
func Handler ¶
Handler serves the config page for the flow config data (JSON), named name in messages, checked against reg (nil: structural only, as the bide view command checks it): the page at / and its view as JSON at /config.json. It answers only GET and HEAD requests addressed to a loopback host.
Types ¶
This section is empty.