{"modulePath":"github.com/contenox/runtime","version":"v0.0.76","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package executor\n\n## Types\n\n```go\ntype ExecutorManager interface {\n\tStartSync(ctx context.Context, syncInterval time.Duration)\n\tStopSync()\n\tExecutorSyncTrigger\n\n\teventdispatch.Executor\n}\n```\n\n```go\ntype ExecutorSyncTrigger interface {\n\tTriggerSync()\n}\n```\n\n```go\ntype GojaExecutor struct {\n\t// contains filtered or unexported fields\n}\n```\nGojaExecutor handles JavaScript function execution using goja VM with pre-compiled functions. It provides a secure sandboxed environment for executing user-provided JavaScript code with access to system services through controlled built-in functions.\n\n```go\nfunc NewGojaExecutor(\n\ttracker libtracker.ActivityTracker,\n\tfunctionService functionservice.Service,\n) *GojaExecutor\n```\nNewGojaExecutor creates a new Goja executor with VM pool and function cache.\n\nParameters:\n\n  - tracker: Activity tracker for monitoring execution\n  - functionService: Service for synchronizing function-scripts\n\nReturns:\n\n  - Executor: A new GojaExecutor instance\n\n```go\nfunc (e *GojaExecutor) AddBuildInServices(\n\teventsource eventsourceservice.Service,\n\ttaskService execservice.ExecService,\n\ttaskchainService taskchainservice.Service,\n\ttaskchainExecService execservice.TasksEnvService,\n)\n```\n\n```go\nfunc (e *GojaExecutor) ExecuteFunction(\n\tctx context.Context,\n\tcode string,\n\tfunctionName string,\n\tevent *eventstore.Event,\n) (map[string]interface{}, error)\n```\nExecuteFunction executes a JavaScript function with the given event as input.\n\nParameters:\n\n  - ctx: Execution context\n  - code: JavaScript code to execute\n  - functionName: Name of the function to call (or use global result)\n  - event: Event that triggered the function execution\n\nReturns:\n\n  - map\\[string]interface{}: Function result as a JSON-like map\n  - error: Any error encountered during execution\n\n```go\nfunc (e *GojaExecutor) StartSync(ctx context.Context, syncInterval time.Duration)\n```\nStartSync begins background synchronization of the function cache Parameters:\n\n  - ctx: Context for managing the sync lifecycle\n  - syncInterval: How often to perform automatic syncs\n\n```go\nfunc (e *GojaExecutor) StopSync()\n```\nStopSync stops the background synchronization\n\n```go\nfunc (e *GojaExecutor) TriggerSync()\n```\nTriggerSync manually triggers a synchronization\n\n","path":"github.com/contenox/runtime/executor","name":"executor","synopsis":"","isRedistributable":true}
