compiler

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

This compiler was inspired from grafana k6 project A big kudos goes to goja library Do check it out: https://github.com/dop251/goja

Index

Constants

This section is empty.

Variables

View Source
var ErrExceptionInPluginCode = errors.New("plugin code error")

Functions

func NewRuntime

func NewRuntime() *goja.Runtime

Types

type Babel

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

type Compiler

type Compiler struct {
	ModuleLoader *modules.ModuleLoader
	// contains filtered or unexported fields
}

func New

func New(logger Logger) (*Compiler, error)

func (*Compiler) Run

func (c *Compiler) Run(pgm *goja.Program, cfg *RunConfig, ruleOpt map[string]any) error

func (*Compiler) Transform

func (c *Compiler) Transform(rawCode string) (*goja.Program, error)

type KeyValuePairs

type KeyValuePairs struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type Logger

type Logger interface {
	Info(str string)
	Warn(str string)
	Error(str string)
	Log(str string)
}

type RunConfig

type RunConfig struct {
	ApiSchema map[string]interface{}               `json:"schema"`
	Type      string                               `json:"type"`
	SetScore  func(category string, score float32) `json:"setScore"`
	Report    func(body *reportmanager.ReportDef)  `json:"report"`
}

these are the data that will be given to js code execution env

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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