ask

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ComponentName = "ask"
	RequestPort   = "request"
	OutPort       = "out"
	ErrorPort     = "error"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Component

type Component struct {
	module.Base
	// contains filtered or unexported fields
}

Component is a human-in-the-loop gate. Pending questions live in the node's State (same backing as kv/collect: TinyNode status metadata), so they survive pod restarts and are visible to every replica. The Control port can only render ONE form per node, so questions queue FIFO: the oldest is presented first and answering it (or its expiry) reveals the next.

func (*Component) GetInfo

func (c *Component) GetInfo() module.ComponentInfo

func (*Component) Handle

func (c *Component) Handle(ctx context.Context, _ module.Handler, port string, msg any) module.Result

Handle opens the gate. It returns immediately: the run does not stay parked waiting for a human. Continuity lives in this node's persisted queue and published form, and the answer arrives later as a separate control message that starts the downstream hop itself.

func (*Component) Instance

func (c *Component) Instance() module.Component

func (*Component) OnControl

func (c *Component) OnControl(ctx context.Context, msg any) error

OnControl receives the human's submission. The form has no Go type — its shape is only known at runtime — so the runtime decodes it into the map this port advertises as its configuration, and the submitted values arrive here as that map rather than a typed struct.

func (*Component) OnReconcile added in v0.9.0

func (c *Component) OnReconcile(ctx context.Context, _ v1alpha1.TinyNode) error

OnReconcile is the rehydration hook and the idle expiry tick. The queue itself needs no restoring — State reads through the cluster cache — but after a pod restart the widget must be re-shown the outstanding question, and reconcile ticks are the only traffic an otherwise idle node ever sees.

func (*Component) OnSettings

func (c *Component) OnSettings(_ context.Context, msg any) error

func (*Component) Ports

func (c *Component) Ports() []module.Port

type Context

type Context any

Context is the passthrough payload — whatever the flow was carrying when it reached the gate. It rides through the human's decision unchanged so the downstream action knows what it is acting on.

type ErrorMessage added in v0.9.0

type ErrorMessage struct {
	Context Context `json:"context,omitempty" title:"Context" description:"The request payload of the expired question, unchanged."`
	Error   string  `json:"error" title:"Error"`
}

ErrorMessage reports a question nobody answered in time.

type Reply

type Reply struct {
	Values  map[string]interface{} `json:"values" title:"Values" description:"What the human submitted, keyed by the form's field names."`
	Context Context                `json:"context,omitempty" title:"Context" description:"The request payload, unchanged."`
}

Reply is emitted once a human submits the form.

type Request

type Request struct {
	Context Context `` /* 152-byte string literal not displayed */
}

Request is what the flow sends to open the gate. The form is fixed by Settings; this carries the thing being decided on.

type Settings

type Settings struct {
	// Form is a JSON Schema rendered as the question put to the human. It is
	// authored here rather than derived from a Go type, which is the whole
	// point: the same component asks "approve this restart?" or "how many
	// replicas?" depending on what is written here.
	Form string `` /* 234-byte string literal not displayed */
	// TimeoutSeconds bounds how long a question may wait for a human. Zero
	// keeps the original behavior: wait forever.
	TimeoutSeconds int `` /* 311-byte string literal not displayed */
	// EnableErrorPort follows the standard pattern (see collect): without it
	// expired questions are dropped with only a log line.
	EnableErrorPort bool `` /* 253-byte string literal not displayed */
}

Jump to

Keyboard shortcuts

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