From b4769eefd9fee58ea5abc7d94d95977d5407939c Mon Sep 17 00:00:00 2001 From: James Shubin Date: Mon, 17 Mar 2025 02:26:36 -0400 Subject: [PATCH] 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. --- lang/funcs/facts/facts.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lang/funcs/facts/facts.go b/lang/funcs/facts/facts.go index 2b1a33d1..7a372fee 100644 --- a/lang/funcs/facts/facts.go +++ b/lang/funcs/facts/facts.go @@ -106,7 +106,14 @@ type Fact interface { Info() *Info Init(*Init) 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) }