executor

package
v0.0.76 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExecutorManager

type ExecutorManager interface {
	StartSync(ctx context.Context, syncInterval time.Duration)
	StopSync()
	ExecutorSyncTrigger

	eventdispatch.Executor
}

type ExecutorSyncTrigger

type ExecutorSyncTrigger interface {
	TriggerSync()
}

type GojaExecutor

type GojaExecutor struct {
	// contains filtered or unexported fields
}

GojaExecutor 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.

func NewGojaExecutor

func NewGojaExecutor(
	tracker libtracker.ActivityTracker,
	functionService functionservice.Service,
) *GojaExecutor

NewGojaExecutor creates a new Goja executor with VM pool and function cache.

Parameters:

  • tracker: Activity tracker for monitoring execution
  • functionService: Service for synchronizing function-scripts

Returns:

  • Executor: A new GojaExecutor instance

func (*GojaExecutor) AddBuildInServices

func (e *GojaExecutor) AddBuildInServices(
	eventsource eventsourceservice.Service,
	taskService execservice.ExecService,
	taskchainService taskchainservice.Service,
	taskchainExecService execservice.TasksEnvService,
)

func (*GojaExecutor) ExecuteFunction

func (e *GojaExecutor) ExecuteFunction(
	ctx context.Context,
	code string,
	functionName string,
	event *eventstore.Event,
) (map[string]interface{}, error)

ExecuteFunction executes a JavaScript function with the given event as input.

Parameters:

  • ctx: Execution context
  • code: JavaScript code to execute
  • functionName: Name of the function to call (or use global result)
  • event: Event that triggered the function execution

Returns:

  • map[string]interface{}: Function result as a JSON-like map
  • error: Any error encountered during execution

func (*GojaExecutor) StartSync

func (e *GojaExecutor) StartSync(ctx context.Context, syncInterval time.Duration)

StartSync begins background synchronization of the function cache Parameters:

  • ctx: Context for managing the sync lifecycle
  • syncInterval: How often to perform automatic syncs

func (*GojaExecutor) StopSync

func (e *GojaExecutor) StopSync()

StopSync stops the background synchronization

func (*GojaExecutor) TriggerSync

func (e *GojaExecutor) TriggerSync()

TriggerSync manually triggers a synchronization

Jump to

Keyboard shortcuts

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