Documentation
¶
Overview ¶
Package flowtemplate provides storage and instantiation for parameterised flow definitions.
A Template is a flow-shaped JSON blob with named substitution points the coordinator agent (or any operator) fills in to produce a concrete flowstore.Flow ready to deploy. Step 4 of ADR-029 Pattern B.
Templating is intentionally minimal for the first pass: Go's text/template over the marshalled JSON body with a Parameters map. Real templating engines (conditionals, ranges over arrays of params) can land when a concrete product use case exceeds string substitution.
Index ¶
- type Manager
- func (m *Manager) Create(ctx context.Context, t *Template) error
- func (m *Manager) Delete(ctx context.Context, id string) error
- func (m *Manager) Get(ctx context.Context, id string) (*Template, error)
- func (m *Manager) List(ctx context.Context) (map[string]*Template, error)
- func (m *Manager) Update(ctx context.Context, t *Template) error
- type Parameter
- type Template
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager provides CRUD against the FLOW_TEMPLATES KV bucket plus the Instantiate operation. Pattern-B per ADR-029 with one type-specific extension (Instantiate) on top of the canonical Save/Get/Delete/List.
func NewManager ¶
func NewManager(natsClient *natsclient.Client) (*Manager, error)
NewManager opens (or creates) the FLOW_TEMPLATES bucket.
type Parameter ¶
type Parameter struct {
// Name matches the placeholder in Body (e.g. "TopicName" for
// {{.TopicName}}).
Name string `json:"name"`
// Description helps the coordinator / operator pick a value.
Description string `json:"description,omitempty"`
// Default is the value used when Instantiate is called without
// overriding this parameter. Empty means "required — no default".
Default string `json:"default,omitempty"`
// Required signals the caller must supply a value (no default).
// When Required is true, Default is ignored.
Required bool `json:"required,omitempty"`
}
Parameter declares one substitution point on a Template.
type Template ¶
type Template struct {
// ID uniquely identifies the template in the FLOW_TEMPLATES bucket.
// Kebab-case convention: "research-pipeline", "temp-anomaly-agent".
ID string `json:"id"`
// Name is a human-friendly label surfaced to operators and the
// coordinator agent when choosing a template.
Name string `json:"name"`
// Description is optional context explaining what this template
// produces and when to use it — surfaced to the coordinator so it
// can pick sensibly.
Description string `json:"description,omitempty"`
// Body is the flow definition with text/template placeholders. When
// instantiated, placeholders resolve against user-supplied Parameters.
// Canonical substitution syntax: {{.SomeParam}}.
Body string `json:"body"`
// Parameters declares the substitution points and their defaults.
// Instantiate() uses defaults for any param the caller omits. Order
// of Parameters is not significant — the slice form is just to
// preserve authoring order for operators scanning the template.
Parameters []Parameter `json:"parameters,omitempty"`
}
Template is the stored form of a parameterised flow definition.
func (*Template) Instantiate ¶
Instantiate renders the template into a concrete flowstore.Flow using the supplied parameter values. Unsupplied parameters fall back to Default. Required parameters with no supplied value return an error so callers see the problem before JSON decoding.