javascript

package
v0.0.0-...-a83d8fc Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddSessionHook

func AddSessionHook(name string, mod SessionHook)

AddSessionHook registers a SessionHook that gets invoked for each new Session.

func NewFromConfig

func NewFromConfig(c Config) (pipeline.Filter, error)

NewFromConfig constructs a new Javascript processor from the given config object. It loads the sources, compiles them, and validates the entry point.

func NewJavascriptFilter

func NewJavascriptFilter(c *config.Config) (pipeline.Filter, error)

Types

type Config

type Config struct {
	Tag               string                 `config:"tag"`                                  // Processor ID for debug and metrics.
	Source            string                 `config:"source"`                               // Inline script to execute.
	File              string                 `config:"file"`                                 // Source file.
	Files             []string               `config:"files"`                                // Multiple source files.
	Params            map[string]interface{} `config:"params"`                               // Parameters to pass to script.
	Timeout           time.Duration          `config:"timeout" validate:"min=0"`             // Execution timeout.
	TagOnException    string                 `config:"tag_on_exception"`                     // Tag to add to events when an exception happens.
	MaxCachedSessions int                    `config:"max_cached_sessions" validate:"min=0"` // Max. number of cached VM sessions.
}

Config defines the Javascript source files to use for the processor.

func (Config) Validate

func (c Config) Validate() error

Validate returns an error if one (and only one) option is not set.

type Event

type Event interface {
	// Cancel marks the event as cancelled such that it will be dropped.
	Cancel()

	// IsCancelled returns true if Cancel has been invoked.
	IsCancelled() bool

	// Wrapped returns the underlying pipeline.Context being wrapped. The wrapped
	// event is replaced each time a new event is processed.
	Wrapped() *fasthttp.RequestCtx

	// JSObject returns the Value that represents this object within the
	// runtime.
	JSObject() goja.Value
	// contains filtered or unexported methods
}

Event is the event being processed by the processor.

type Session

type Session interface {
	// Runtime returns the Javascript runtime used for this session.
	Runtime() *goja.Runtime

	// Event returns a pointer to the current event being processed.
	Event() Event
}

Session is an instance of the processor.

type SessionHook

type SessionHook func(s Session)

SessionHook is a function that get invoked when each new Session is created.

Directories

Path Synopsis
net
windows
Package windows registers the windows module with the javascript script processor.
Package windows registers the windows module with the javascript script processor.

Jump to

Keyboard shortcuts

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