runtime

package
v0.0.0-...-5655933 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// LineCount counts the number of lines received by the program loader.
	LineCount = expvar.NewInt("lines_total")
	// ProgLoads counts the number of program load events.
	ProgLoads = expvar.NewMap("prog_loads_total")
	// ProgUnloads counts the number of program unload events.
	ProgUnloads = expvar.NewMap("prog_unloads_total")
	// ProgLoadErrors counts the number of program load errors.
	ProgLoadErrors = expvar.NewMap("prog_load_errors_total")
)

Functions

This section is empty.

Types

type Option

type Option func(*Runtime) error

Option configures a new program Runtime.

func CompileOnly

func CompileOnly() Option

CompileOnly sets the Runtime to compile programs only, without executing them.

func DumpAst

func DumpAst() Option

DumpAst emits the AST after program compilation.

func DumpAstTypes

func DumpAstTypes() Option

DumpAstTypes emits the AST after type checking.

func DumpBytecode

func DumpBytecode() Option

DumpBytecode instructs the loader to print the compiled bytecode after code generation.

func ErrorsAbort

func ErrorsAbort() Option

ErrorsAbort sets the Runtime to abort the Runtime on compile errors.

func LogRuntimeErrors

func LogRuntimeErrors() Option

LogRuntimeErrors instructs the VM to emit runtime errors into the log.

func MaxRecursionDepth

func MaxRecursionDepth(maxRecursionDepth int) Option

MaxRecursionDepth sets the maximum depth the abstract syntax tree built during lexation can have.

func MaxRegexpLength

func MaxRegexpLength(maxRegexpLength int) Option

MaxRegexpLength sets the maximum length an mtail regular expression can have, in terms of characters.

func OmitMetricSource

func OmitMetricSource() Option

OmitMetricSource instructs the Runtime to not annotate metrics with their program source when added to the metric store.

func OverrideLocation

func OverrideLocation(loc *time.Location) Option

OverrideLocation sets the timezone location for the VM.

func PrometheusRegisterer

func PrometheusRegisterer(reg prometheus.Registerer) Option

PrometheusRegisterer passes in a registry for setting up exported metrics.

func SyslogUseCurrentYear

func SyslogUseCurrentYear() Option

SyslogUseCurrentYear instructs the VM to annotate yearless timestamps with the current year.

func TraceExecution

func TraceExecution() Option

type Runtime

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

Runtime handles the lifecycle of programs and virtual machines, by watching the configured program source directory, compiling changes to programs, and managing the virtual machines.

func New

func New(lines <-chan *logline.LogLine, wg *sync.WaitGroup, programPath string, store *metrics.Store, options ...Option) (*Runtime, error)

New creates a new program loader that reads programs from programPath.

func (*Runtime) CompileAndRun

func (r *Runtime) CompileAndRun(name string, input io.Reader) error

CompileAndRun compiles a program read from the input, starting execution if it succeeds. If an existing virtual machine of the same name already exists, the previous virtual machine is terminated and the new loaded over it. If the new program fails to compile, any existing virtual machine with the same name remains running.

func (*Runtime) LoadAllPrograms

func (r *Runtime) LoadAllPrograms() error

LoadAllPrograms loads all programs in a directory and starts watching the directory for filesystem changes. Any compile errors are stored for later retrieival. This function returns an error if an internal error occurs.

func (*Runtime) LoadProgram

func (r *Runtime) LoadProgram(programPath string) error

LoadProgram loads or reloads a program from the full pathname programPath. The name of the program is the basename of the file.

func (*Runtime) ProgzHandler

func (r *Runtime) ProgzHandler(w http.ResponseWriter, req *http.Request)

func (*Runtime) SetOption

func (r *Runtime) SetOption(options ...Option) error

SetOption takes one or more option functions and applies them in order to Runtime.

func (*Runtime) UnloadProgram

func (r *Runtime) UnloadProgram(pathname string)

UnloadProgram removes the named program, any currently running VM goroutine.

func (*Runtime) WriteStatusHTML

func (r *Runtime) WriteStatusHTML(w io.Writer) error

WriteStatusHTML writes the current state of the loader as HTML to the given writer w.

Directories

Path Synopsis
Package code contains the bytecode instructions for the mtail virtual machine.
Package code contains the bytecode instructions for the mtail virtual machine.
ast
opt
package opt has a compiler pass for making optimisations on the AST.
package opt has a compiler pass for making optimisations on the AST.
parser
Package parser implements the parse phase of the mtail program compilation.
Package parser implements the parse phase of the mtail program compilation.
position
Package position implements a data structure for storing source code positions.
Package position implements a data structure for storing source code positions.
Package vm provides a virtual machine environment for executing mtail bytecode.
Package vm provides a virtual machine environment for executing mtail bytecode.

Jump to

Keyboard shortcuts

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