Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Task ¶
type Task struct {
Process string // Process name (e.g. "scripts.runtime.basic.Hello")
Args []interface{} // Process arguments
Timeout int // Timeout in seconds (0 = use default 30s)
}
Task represents a single process call to execute concurrently.
func ParseTasks ¶
ParseTasks extracts a []Task from the first JS argument (an array of {process, args} objects). Returns nil and an error string if parsing fails.
type TaskResult ¶
type TaskResult struct {
Data interface{} `json:"data"` // Return value on success
Error string `json:"error,omitempty"` // Error message on failure
Index int `json:"index"` // Original task index (preserves order)
}
TaskResult holds the outcome of a single concurrent task.
func ParallelAll ¶
func ParallelAll(tasks []Task, share *bridge.Share) []TaskResult
ParallelAll executes all tasks concurrently and waits for every task to complete. Semantics: Promise.all — all results returned, order preserved.
func ParallelAny ¶
func ParallelAny(tasks []Task, share *bridge.Share) []TaskResult
ParallelAny executes all tasks concurrently and returns once the first task succeeds. Semantics: Promise.any — first success wins; all tasks still run to completion to avoid leaks. A "success" is defined as data != nil and error == "".
func ParallelRace ¶
func ParallelRace(tasks []Task, share *bridge.Share) []TaskResult
ParallelRace executes all tasks concurrently and returns once the first task completes. Semantics: Promise.race — first completion wins (success or failure).