call

package
v0.37.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package call implements the bind and expand engine for parameterized provider calls (spec.calls). It is a pure utility over pkg/spec: it binds already-resolved call-site argument values against a Call definition's declared arguments and builds the enriched evaluation data that exposes those arguments under the "args" namespace. It deliberately imports only pkg/spec so that provider dispatch (which lives in the resolver and action executors) can depend on it without creating an import cycle.

Index

Constants

View Source
const ArgsNamespace = "args"

ArgsNamespace is the key under which bound arguments are exposed in the evaluation data. Definition inputs reference arguments as _.args.x (CEL) and {{ .args.x }} (Go templates).

Variables

This section is empty.

Functions

func BindArgs

func BindArgs(callName string, def *spec.Call, resolved map[string]any) (map[string]any, error)

BindArgs binds already-resolved call-site argument values against a Call definition's ArgDefs. It rejects unknown arguments, enforces required arguments, applies defaults for omitted optional arguments, and coerces every value to its declared type. The returned map contains exactly the declared arguments. callName is included in all error messages so diagnostics are call-site aware.

func DedupKey

func DedupKey(callName string, boundArgs map[string]any) (string, error)

DedupKey builds a stable, canonical de-duplication key for a call invocation. The key combines the call name with a canonical JSON encoding of the bound arguments so that logically-equal argument sets collide regardless of the order in which they were written. Bound arguments must already be coerced.

func ExpandData

func ExpandData(resolverData, boundArgs map[string]any) map[string]any

ExpandData returns a shallow copy of resolverData with the bound arguments injected under the args namespace so definition inputs and the invoked provider can reference them as _.args.x and {{ .args.x }}. The input map is not mutated.

Types

type Memo

type Memo struct {
	// contains filtered or unexported fields
}

Memo is a per-run, in-memory memo for opt-in call de-duplication. It is never persisted and is scoped to a single run. Each key computes its value exactly once, even under concurrent access, so identical bound arguments within a run reuse the first result instead of re-invoking the provider.

func NewMemo

func NewMemo() *Memo

NewMemo creates an empty de-duplication memo.

func (*Memo) Do

func (m *Memo) Do(key string, fn func() (any, error)) (any, error)

Do returns the memoized result for key, computing it via fn on first access. Concurrent callers sharing a key block until the first computation completes and then observe the same result.

Jump to

Keyboard shortcuts

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