Help us shape the future of Go! Take the 2026 Go Developer Survey

planview

package
v0.14.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

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

func Check(w io.Writer, name string, data []byte, reg *plan.Registry) bool

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

func Handler(name string, data []byte, reg *plan.Registry) http.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.

func Listen

func Listen(addr string) (net.Listener, error)

Listen listens on addr, which must name a loopback IP or localhost (any other host is refused), for serving Handler: http.Serve(ln, planview.Handler(...)).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL