lang: funcs: facts: Add a separate callable interface

Add some symmetry to our interfaces for now, even though I'd love to
drop the idea of "facts" altogether.
This commit is contained in:
James Shubin
2025-03-17 02:26:36 -04:00
parent d4a24d4c9d
commit b4769eefd9

View File

@@ -106,7 +106,14 @@ type Fact interface {
Info() *Info Info() *Info
Init(*Init) error Init(*Init) error
Stream(context.Context) error Stream(context.Context) error
}
// TODO: should we require this here? What about a CallableFact instead?
Call(context.Context) (types.Value, error) // CallableFact is a function that takes no args, and that can be called
// statically if we want to do it speculatively or from a resource.
type CallableFact interface {
Fact // implement everything in Fact but add the additional requirements
// Call this fact and return the value if it is possible to do so at
// this time.
Call(ctx context.Context) (types.Value, error)
} }