Documentation
¶
Index ¶
- Variables
- func GetCapsuleFromValue(val cty.Value) (interface{}, error)
- func GetContextFromValue(val cty.Value) (context.Context, error)
- func GetFloat32Attr(val cty.Value, attr string) (float32, bool)
- func GetGenericFunctions() map[string]function.Function
- func GetIntAttr(val cty.Value, attr string) (int, bool)
- func GetStringAttr(val cty.Value, attr string) (string, bool)
- func NewContextCapsule(ctx context.Context) cty.Value
- type Callable
- type Clearable
- type ContextObjectBuilder
- func (b *ContextObjectBuilder) Build() (cty.Value, error)
- func (b *ContextObjectBuilder) WithAttribute(name string, value cty.Value) *ContextObjectBuilder
- func (b *ContextObjectBuilder) WithInt64Attribute(name string, value int64) *ContextObjectBuilder
- func (b *ContextObjectBuilder) WithStringAttribute(name string, value string) *ContextObjectBuilder
- func (b *ContextObjectBuilder) WithUInt64Attribute(name string, value uint64) *ContextObjectBuilder
- type Countable
- type Gettable
- type Incrementable
- type Lengthable
- type Observable
- type Resettable
- type Settable
- type Stateful
- type Stringable
- type Watchable
- type WatchableMixin
- type Watcher
Constants ¶
This section is empty.
Variables ¶
var ContextCapsuleType = cty.CapsuleWithOps("_context", reflect.TypeOf((*any)(nil)).Elem(), &cty.CapsuleOps{ GoString: func(val interface{}) string { return fmt.Sprintf("_ctx(%p)", val) }, TypeGoString: func(_ reflect.Type) string { return "_ctx" }, })
ContextCapsuleType is a cty capsule type for wrapping Context instances.
Functions ¶
func GetCapsuleFromValue ¶
GetCapsuleFromValue extracts the encapsulated Go value from a cty capsule, or from an object's _capsule attribute if present. Returns the raw interface{} so callers can type-assert to the interface they need.
Accepts:
- a capsule value directly
- an object with a _capsule attribute that is a capsule
func GetContextFromValue ¶
Gets a context from a value, which must either be a context capsule or an object with a _ctx attribute that is a context capsule.
func GetFloat32Attr ¶
GetFloat32Attr returns an attribute value as a float32 if it exists and is a number.
func GetGenericFunctions ¶
func GetIntAttr ¶
GetIntAttr returns an attribute value as an int if it exists and is a number.
func GetStringAttr ¶
GetStringAttr returns an attribute value as a string if it exists and is a string.
Types ¶
type Callable ¶
Callable is a pure request/response capability. It is not specific to LLM clients and is designed to cover future types (HTTP, JSON-RPC, MCP, etc.). args contains all arguments after the "thing": the implementor fully controls what they mean.
type Clearable ¶
Clearable is implemented by types that support the clear() function. On timer and threshold conditions this cancels any pending state, releases any latch, and (for retentive timers) discards accumulated time. Semantically distinct from Resettable.
type ContextObjectBuilder ¶
ContextObjectBuilder builds a cty object value for use as the "ctx" variable.
func NewContextObject ¶
func NewContextObject(ctx context.Context) *ContextObjectBuilder
NewContextObject creates a new ContextObjectBuilder wrapping the given context.
func (*ContextObjectBuilder) Build ¶
func (b *ContextObjectBuilder) Build() (cty.Value, error)
Build creates the cty object value for the "ctx" variable.
func (*ContextObjectBuilder) WithAttribute ¶
func (b *ContextObjectBuilder) WithAttribute(name string, value cty.Value) *ContextObjectBuilder
func (*ContextObjectBuilder) WithInt64Attribute ¶
func (b *ContextObjectBuilder) WithInt64Attribute(name string, value int64) *ContextObjectBuilder
func (*ContextObjectBuilder) WithStringAttribute ¶
func (b *ContextObjectBuilder) WithStringAttribute(name string, value string) *ContextObjectBuilder
func (*ContextObjectBuilder) WithUInt64Attribute ¶
func (b *ContextObjectBuilder) WithUInt64Attribute(name string, value uint64) *ContextObjectBuilder
type Countable ¶
Countable is implemented by types that maintain a running count accessible via count(). Distinct from Lengthable: Lengthable answers "how many elements does this collection have?"; Countable answers "how many times has this happened?" — it backs counters and run-count accumulators.
type Gettable ¶
Gettable is implemented by types whose current value can be read via get(). args contains all arguments after the "thing": typically args[0] is the default value, but implementors may interpret additional args freely.
type Incrementable ¶
type Incrementable interface {
Increment(ctx context.Context, args []cty.Value) (cty.Value, error)
}
Incrementable is implemented by types that support numeric increment via increment(). args contains all arguments after the "thing": args[0] is the delta; implementors may interpret additional args freely.
type Lengthable ¶
Lengthable is implemented by types that have a meaningful length, allowing them to be used with length().
type Observable ¶
Observable is implemented by types that support observe() (histograms). args contains all arguments after the "thing": args[0] is the observed value; implementors may interpret additional args (e.g. labels) freely.
type Resettable ¶
Resettable is implemented by types that can be reset to an initial state via reset(). Used by counter conditions and watchdog triggers. Distinct from the condition-specific clear() semantics on timer/threshold conditions.
type Settable ¶
Settable is implemented by types whose value can be updated via set(). args contains all arguments after the "thing": args[0] is the value to set; implementors may interpret additional args (e.g. labels) freely.
type Stateful ¶
Stateful is implemented by types that expose a named internal state via state(). Condition blocks implement this with the four-state vocabulary ("inactive", "pending_activation", "active", "pending_deactivation").
type Stringable ¶
Stringable is implemented by types that have a natural string representation, allowing them to be used with tostring().
type Watchable ¶
type Watchable interface {
// Watch registers w to receive OnChange notifications when the value changes.
// Registering the same Watcher twice is a no-op.
Watch(w Watcher)
// Unwatch removes a previously registered Watcher.
// Removing a Watcher that is not registered is a no-op.
Unwatch(w Watcher)
}
Watchable is implemented by types whose value can be observed for changes. Implementations must be safe to call from multiple goroutines concurrently.
type WatchableMixin ¶
type WatchableMixin struct {
// contains filtered or unexported fields
}
WatchableMixin encapsulates watcher-list management for Watchable types. Embedding types must use a separate mutex for their own value; watchMu is used only for the watcher slice.
func (*WatchableMixin) NotifyAll ¶
func (m *WatchableMixin) NotifyAll(ctx context.Context, old, new cty.Value)
NotifyAll snapshots the watcher list and calls OnChange on each entry. Must be called after the embedding type's value mutex has been released.
func (*WatchableMixin) Unwatch ¶
func (m *WatchableMixin) Unwatch(w Watcher)
Unwatch removes a previously registered Watcher. Removing an unregistered Watcher is a no-op.
func (*WatchableMixin) Watch ¶
func (m *WatchableMixin) Watch(w Watcher)
Watch registers w to receive OnChange notifications. Registering the same Watcher twice is a no-op.
type Watcher ¶
type Watcher interface {
// OnChange is called after the Watchable's value has been updated.
// oldValue is the value immediately before the change.
// newValue is the value immediately after the change.
// ctx is the context.Context that was passed to the Set (or Increment) call
// that triggered the change.
OnChange(ctx context.Context, oldValue, newValue cty.Value)
}
Watcher receives notifications from a Watchable when its value changes. OnChange is called synchronously, outside the Watchable's internal mutex.