Documentation ¶
Overview ¶
Package vars implement lucicfg.var() support.
See lucicfg.var() doc for more info.
Index ¶
- type ID
- type Vars
- func (v *Vars) ClearValues()
- func (v *Vars) CloseScope(th *starlark.Thread)
- func (v *Vars) Declare() ID
- func (v *Vars) Get(th *starlark.Thread, id ID, def starlark.Value) (starlark.Value, error)
- func (v *Vars) OpenScope(th *starlark.Thread)
- func (v *Vars) Set(th *starlark.Thread, id ID, value starlark.Value) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ID ¶
type ID int
ID is an opaque starlark value that represents a lucifg.var() variable.
It is just a unique identifier for this particular variable, used as a key in a map with variables values.
type Vars ¶
type Vars struct {
// contains filtered or unexported fields
}
Vars holds definitions and current state of lucicfg.var() variables.
It exposes OpenScope/CloseScope that should be connected to PreExec/PostExec interpreter hooks. They "open" and "close" scopes for variables: all changes made to vars state within a scope (i.e. within single exec-ed module) are discarded when the scope is closed.
func (*Vars) ClearValues ¶
func (v *Vars) ClearValues()
ClearValues resets values of all variables, in all scopes.
Should be used only from tests that want a clean slate.
func (*Vars) CloseScope ¶
CloseScope discards changes made to variables since the matching OpenScope.
func (*Vars) Get ¶
Get returns the value of a variable, auto-initializing it to 'def' if it was unset before.
Variable can be assigned or read only from threads that perform 'exec' calls, NOT when loading library modules via 'load' (the library modules must not have side effects or depend on a transient state in vars), or executing callbacks (callbacks do not have enough context to safely use vars).
func (*Vars) OpenScope ¶
OpenScope opens a new scope for variables.
All changes to variables' values made within this scope are discarded when it is closed.
func (*Vars) Set ¶
Set sets the value of a variable within the current scope iff the variable was unset before (in the current or any parent scopes).
Variable can be assigned or read only from threads that perform 'exec' calls, NOT when loading library modules via 'load' (the library modules must not have side effects or depend on a transient state in vars), or executing callbacks (callbacks do not have enough context to safely use vars).
Freezes the value as a side effect.