autoflow

package
v19.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextFromThread

func ContextFromThread(thread *starlark.Thread) context.Context

func ExecScript

func ExecScript(ctx context.Context, opts *ExecScriptOptions) (starlark.Value, error)

ExecScript runs a Starlark script that must define a top-level `main` function, then calls it as `main(w, *Args, **Kwargs)` and returns the value produced by `main` (which is `starlark.None` when `main` has no explicit return). The script's `main` signature determines which arguments it accepts; supplying an argument it does not declare is an error.

Types

type Backend

type Backend interface {
	Print(msg string)
	Now() time.Time
	Load(ctx context.Context, thread *starlark.Thread, module string) (starlark.StringDict, error)
	Select(ctx context.Context, cases []SelectCase, defaultCase starlark.Value, timeout time.Duration, timeoutValue starlark.Value) (starlark.Value, error)
	// NewChannel constructs a new channel that yields successive values over time.
	NewChannel() Channel
	Sleep(ctx context.Context, duration time.Duration) error
	Timer(duration time.Duration) Future
	WorkflowKey() string
	// Gather waits for all given sources. Each source is either a Future or a
	// Channel. If returnList is false it returns the single source's value;
	// otherwise it returns a starlark.List of values. If timeout is non-zero and
	// elapses before all sources are ready, it returns timeoutValue instead of a
	// result.
	Gather(ctx context.Context, sources []any, timeout time.Duration, timeoutValue starlark.Value, returnList bool) (starlark.Value, error)
	// Poll invokes action repeatedly until check (a CEL expression over the
	// action's returned value, bound as `ret`) is satisfied, re-attempting every
	// interval until timeout elapses. It returns a Future whose Get() yields the
	// action's value on success, or timeoutValue once timeout elapses without
	// check passing.
	Poll(ctx context.Context, action starlark.Callable, check string, args starlark.Tuple, kwargs []starlark.Tuple, interval, timeout time.Duration, timeoutValue starlark.Value) (Future, error)
}

Backend is the interface of AutoFlow backend implementation.

type Channel added in v19.2.0

type Channel interface {
	// Receive blocks until the next value is available and returns it.
	Receive() (starlark.Value, error)
	// Name is the channel's identity.
	Name() string
}

Channel is a result of an asynchronous operation that yields zero or more values over time, similar to a Go channel. Receive may be called repeatedly to obtain successive values.

type ChannelType added in v19.2.0

type ChannelType struct {
	C Channel
}

ChannelType is the Starlark representation of a channel.

func (*ChannelType) Freeze added in v19.2.0

func (c *ChannelType) Freeze()

func (*ChannelType) Hash added in v19.2.0

func (c *ChannelType) Hash() (uint32, error)

func (*ChannelType) String added in v19.2.0

func (c *ChannelType) String() string

func (*ChannelType) Truth added in v19.2.0

func (c *ChannelType) Truth() starlark.Bool

func (*ChannelType) Type added in v19.2.0

func (c *ChannelType) Type() string

type ExecScriptOptions

type ExecScriptOptions struct {
	Definition []byte
	Backend    Backend
	Tracer     trace.Tracer
	// Args and Kwargs are the positional and keyword arguments bound to the
	// workflow's main() parameters, i.e. main(w, *Args, **Kwargs). Each Kwargs
	// tuple is a (name, value) pair. They are only ever passed as call
	// arguments; the script cannot reach them any other way.
	Args   []starlark.Value
	Kwargs []starlark.Tuple
}

type Future

type Future interface {
	Get() (starlark.Value, error)
}

type FutureType

type FutureType struct {
	F Future
}

func (*FutureType) Freeze

func (f *FutureType) Freeze()

func (*FutureType) Hash

func (f *FutureType) Hash() (uint32, error)

func (*FutureType) String

func (f *FutureType) String() string

func (*FutureType) Truth

func (f *FutureType) Truth() starlark.Bool

func (*FutureType) Type

func (f *FutureType) Type() string

type SelectCase added in v19.2.0

type SelectCase struct {
	Name string
	// Source is the value the case waits on. It holds either a Future or a
	// Channel.
	Source any
}

Jump to

Keyboard shortcuts

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