package lang

import "github.com/purpleidea/mgmt/lang"

Package lang is the mcl language frontend that implements the reactive DSL that lets users model their desired state over time.

Index

Constants

const (
	// EngineStartupStatsTimeout is the amount of time in seconds to wait
	// between engine startup, and loaded event before printing some
	// debugging stats. This is useful for finding bugs in the function
	// engine. Set to zero to disable.
	EngineStartupStatsTimeout = 60
)

Types

type Data

type Data struct {
	// UnificationStrategy is a hack to tune unification performance until
	// we have an overall cleaner unification algorithm in place.
	UnificationStrategy map[string]string
}

Data is some data that is passed into the Lang struct. It is presented here as a single struct with room for multiple fields so that it can be changed or extended in the future without having to re-plumb through all the fields it contains

type Lang

type Lang struct {
	Fs    engine.Fs // connected fs where input dir or metadata exists
	FsURI string

	// Input is a string which specifies what the lang should run. It can
	// accept values in several different forms. If is passed a single dash
	// (-), then it will use `os.Stdin`. If it is passed a single .mcl file,
	// then it will attempt to run that. If it is passed a directory path,
	// then it will attempt to run from there. Instead, if it is passed the
	// path to a metadata file, then it will attempt to parse that and run
	// from that specification. If none of those match, it will attempt to
	// run the raw string as mcl code.
	Input string

	// Data is some additional data for the lang struct.
	Data *Data

	Hostname string
	Local    *local.API
	World    engine.World
	Prefix   string
	Debug    bool
	Logf     func(format string, v ...interface{})
	// contains filtered or unexported fields
}

Lang is the main language lexer/parser object.

func (*Lang) Cleanup

func (obj *Lang) Cleanup() error

Cleanup cleans up and frees memory and resources after everything is done.

func (*Lang) Init

func (obj *Lang) Init(ctx context.Context) error

Init initializes the lang struct, and starts up the initial input parsing. NOTE: The trick is that we need to get the list of funcs to watch AND start watching them, *before* we pull their values, that way we'll know if they changed from the values we wanted.

func (*Lang) Interpret

func (obj *Lang) Interpret() (*pgraph.Graph, error)

Interpret runs the interpreter and returns a graph and corresponding error.

func (*Lang) Run

func (obj *Lang) Run(ctx context.Context) (reterr error)

Run kicks off the function engine. Use the context to shut it down.

func (*Lang) Stream

func (obj *Lang) Stream() <-chan error

Stream returns a channel of graph change requests or errors. These are usually sent when a func output changes.

Source Files

lang.go

Directories

PathSynopsis
lang/astPackage ast contains the structs implementing and some utility functions for interacting with the abstract syntax tree for the mcl language.
lang/corePackage core contains core functions and other related facilities which are used in programs.
lang/core/convert
lang/core/datetime
lang/core/deploy
lang/core/embedded
lang/core/embedded/provisioner
lang/core/example
lang/core/example/nested
lang/core/fmt
lang/core/golang
lang/core/iter
lang/core/list
lang/core/local
lang/core/map
lang/core/math
lang/core/net
lang/core/os
lang/core/regexp
lang/core/strings
lang/core/sys
lang/core/test
lang/core/util
lang/core/value
lang/core/world
lang/downloadPackage download is used for downloading language modules from git.
lang/embeddedPackage embedded embeds mcl modules into the system import namespace.
lang/funcsPackage funcs provides a framework for functions that change over time.
lang/funcs/dagePackage dage implements a DAG function engine.
lang/funcs/factsPackage facts provides a framework for language values that change over time.
lang/funcs/funcgen
lang/funcs/funcgen/utilPackage util provides some functions to be imported by the generated file.
lang/funcs/multi
lang/funcs/operatorsPackage operators provides a helper library to load all of the built-in operators, which are actually just functions.
lang/funcs/refPackage ref implements reference counting for the graph API and function engine.
lang/funcs/simple
lang/funcs/structs
lang/funcs/txnPackage txn contains the implementation of the graph transaction system.
lang/funcs/varsPackage vars provides a framework for language vars.
lang/funcs/wrapped
lang/fuzz
lang/gapiPackage gapi is the Graph API implementation for the mcl language frontend.
lang/inputsPackage inputs contains the input parsing logic for how mcl module entrypoints are handled for the language.
lang/interfacesPackage interfaces contains the common interfaces used in the mcl language.
lang/interpolatePackage interpolate contains the string interpolation parser and associated structs and code.
lang/interpretPackage interpret contains the implementation of the actual interpret function that takes an AST and returns a resource graph.
lang/parserPackage parser contains the lexer and parser for the mcl language.
lang/typesPackage types provides a framework for our mcl language values and types.
lang/types/full
lang/unificationPackage unification contains the code related to type unification for the mcl language.
lang/unification/fastsolverPackage fastsolver implements very fast type unification.
lang/unification/solversPackage solvers is used to have a central place to import all solvers from.
lang/unification/utilPackage util contains some utility functions and algorithms which are useful for type unification.
lang/utilPackage util contains utility functions that are specific to the mcl language.
Version
v0.0.0-20250322185616-c50a578426f1 (latest)
Published
Mar 22, 2025
Platform
linux/amd64
Imports
22 packages
Last checked
5 days ago

Tools for package owners.