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 ¶
NewFromConfig constructs a new Javascript processor from the given config object. It loads the sources, compiles them, and validates the entry point.
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.
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.
Click to show internal directories.
Click to hide internal directories.