Documentation
¶
Index ¶
- func ExecScript(opts ScriptOptions) error
- type Builtins
- type EventHandlerContext
- type Future
- type FutureType
- func (f *FutureType) CallInternal(thread *starlark.Thread, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)
- func (f *FutureType) Freeze()
- func (f *FutureType) Hash() (uint32, error)
- func (f *FutureType) Name() string
- func (f *FutureType) String() string
- func (f *FutureType) Truth() starlark.Bool
- func (f *FutureType) Type() string
- func (f *FutureType) Unwrap() any
- type HTTPResponse
- type ModuleRef
- type ModuleSource
- type PreloadedRuntimeOptions
- type Runtime
- type RuntimeOptions
- type ScriptOptions
- type Source
- type TestingSource
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecScript ¶
func ExecScript(opts ScriptOptions) error
ExecScript runs a self-contained Starlark script with `w` predeclared as a module wrapping the given EventHandlerContext, plus the standard `time`, `json`, `math` modules. load() is forbidden.
Types ¶
type EventHandlerContext ¶
type EventHandlerContext interface {
HTTPDo(reqURL string, method string, query url.Values, header http.Header, body []byte) (*HTTPResponse, error)
Select(cases *starlark.Dict, defaultCase starlark.Value, timeout time.Duration, timeoutValue starlark.Value) (starlark.Value, error)
Signal(workflowID, signalName, payloadJSON, runID string) (bool, error)
ReceiveChannel(channelName string) (Future, error)
Sleep(duration time.Duration) error
Timer(duration time.Duration) Future
WorkflowID() string
// Gather waits for all given futures. If returnList is false it returns the
// single future's value; otherwise it returns a starlark.List of values.
// If timeout is non-zero and elapses before all futures are ready, it returns
// timeoutValue instead of a result.
Gather(futures []Future, timeout time.Duration, timeoutValue starlark.Value, returnList bool) (starlark.Value, error)
// Run schedules a built-in activity identified by uri and returns a Future
// whose Get() yields the activity's decoded output value. args are the
// remaining positional arguments in stringified form; their meaning is
// uri-specific and opaque to the engine.
Run(uri string, args []string) (Future, error)
}
EventHandlerContext defines an interface for DSL functionalities TODO: eventually abstract starlark types away ... maybe?!
type FutureType ¶
type FutureType struct {
// contains filtered or unexported fields
}
func (*FutureType) CallInternal ¶
func (*FutureType) Freeze ¶
func (f *FutureType) Freeze()
func (*FutureType) Hash ¶
func (f *FutureType) Hash() (uint32, error)
func (*FutureType) Name ¶
func (f *FutureType) Name() string
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
func (*FutureType) Unwrap ¶
func (f *FutureType) Unwrap() any
type HTTPResponse ¶
type ModuleRef ¶
type ModuleSource ¶
type PreloadedRuntimeOptions ¶
type PreloadedRuntimeOptions struct {
ProjectPath string
Entrypoint string
Builtins Builtins
Modules []ModuleSource
}
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
func NewRuntimeFromPreloadedSource ¶
func NewRuntimeFromPreloadedSource(ctx context.Context, opts PreloadedRuntimeOptions) (*Runtime, error)
func NewRuntimeFromSource ¶
func NewRuntimeFromSource(ctx context.Context, opts RuntimeOptions) (*Runtime, error)
func (*Runtime) EvaluateEventHandlerIDs ¶
func (*Runtime) Execute ¶
func (r *Runtime) Execute(eventType string, eventHandlerID uint32, ctx EventHandlerContext, vars starlark.StringDict, event *starlark.Dict) error
func (*Runtime) LoadedModules ¶
func (r *Runtime) LoadedModules() []ModuleSource
type RuntimeOptions ¶
type ScriptOptions ¶
type ScriptOptions struct {
Definition []byte
Context EventHandlerContext
Builtins Builtins
// ExtraWMembers are merged into the `w` Starlark module alongside the
// event-handler-context members (vars, http, sleep, run, ...). Used to
// inject script-mode-only globals such as `w.secrets`.
ExtraWMembers starlark.StringDict
}
ScriptOptions configures a single execution of a self-contained Starlark script via ExecScript. Unlike the source-loaded path, script mode has no load() support and no entrypoint resolution: the bytes are executed top-to-bottom in a fresh thread.
type Source ¶
type Source interface {
// SetupThreadLocal configures thread local variables for this source.
// projectPath is GitLab project path of the entrypoint project.
SetupThreadLocal(thread *starlark.Thread, projectPath string)
// RecordSource
// fullGitRef is the full git reference:
// - refs/heads/<name> for branches
// - refs/tags/<name> for tags
// - <commit id> for commits
// - empty string or HEAD to use the default branch.
RecordSource(thread *starlark.Thread, name, projectPath, fullGitRef string) error
LoadFile(ctx context.Context, thread *starlark.Thread, ref ModuleRef) ([]byte, error)
}
type TestingSource ¶
type TestingSource = preloadedSource
func NewTestingSource ¶
func NewTestingSource(modules []ModuleSource) *TestingSource
Click to show internal directories.
Click to hide internal directories.