plugin

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package plugin provides a goja-based JavaScript plugin registry. OSS users drop .js files into the configured plugin directory; each file can call on(eventName, fn) to subscribe to domain events. Handlers run asynchronously with a 5-second timeout per invocation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load(dir string, registry *Registry, log *slog.Logger) error

Load scans dir for *.js files and evaluates each into the Registry. Scripts call on(eventName, fn) to register handlers. If dir is empty or does not exist, Load is a no-op.

Types

type Registry

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

Registry holds plugin event handlers loaded from JS files.

func NewRegistry

func NewRegistry(log *slog.Logger) *Registry

NewRegistry creates an empty Registry.

func (*Registry) Emit

func (r *Registry) Emit(_ context.Context, event string, payload map[string]any)

Emit fires all registered handlers for event asynchronously. Each handler runs in its own goroutine; errors and panics are logged and swallowed.

Jump to

Keyboard shortcuts

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