Documentation
¶
Index ¶
- Variables
- type Option
- func CompileOnly() Option
- func DumpAst() Option
- func DumpAstTypes() Option
- func DumpBytecode() Option
- func ErrorsAbort() Option
- func LogRuntimeErrors() Option
- func MaxRecursionDepth(maxRecursionDepth int) Option
- func MaxRegexpLength(maxRegexpLength int) Option
- func OmitMetricSource() Option
- func OverrideLocation(loc *time.Location) Option
- func PrometheusRegisterer(reg prometheus.Registerer) Option
- func SyslogUseCurrentYear() Option
- func TraceExecution() Option
- type Runtime
- func (r *Runtime) CompileAndRun(name string, input io.Reader) error
- func (r *Runtime) LoadAllPrograms() error
- func (r *Runtime) LoadProgram(programPath string) error
- func (r *Runtime) ProgzHandler(w http.ResponseWriter, req *http.Request)
- func (r *Runtime) SetOption(options ...Option) error
- func (r *Runtime) UnloadProgram(pathname string)
- func (r *Runtime) WriteStatusHTML(w io.Writer) error
Constants ¶
This section is empty.
Variables ¶
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 ¶
Option configures a new program Runtime.
func CompileOnly ¶
func CompileOnly() Option
CompileOnly sets the Runtime to compile programs only, without executing them.
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 ¶
MaxRecursionDepth sets the maximum depth the abstract syntax tree built during lexation can have.
func MaxRegexpLength ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
SetOption takes one or more option functions and applies them in order to Runtime.
func (*Runtime) UnloadProgram ¶
UnloadProgram removes the named program, any currently running VM goroutine.
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. |
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. |