Documentation ¶
Overview ¶
Package facts provides a framework for language values that change over time.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var RegisteredFacts = make(map[string]func() Fact) // must initialize
RegisteredFacts is a global map of all possible facts which can be used. You should never touch this map directly. Use methods like Register instead.
Functions ¶
func ModuleRegister ¶
ModuleRegister is exactly like Register, except that it registers within a named module. This is a helper function.
Types ¶
type Fact ¶
type Fact interface { //Validate() error // currently not needed since no facts are internal Info() *Info Init(*Init) error Stream() error Close() error }
Fact is the interface that any valid fact must fulfill. It is very simple, but still event driven. Facts should attempt to only send values when they have changed. TODO: should we support a static version of this interface for facts that never change to avoid the overhead of the goroutine and channel listener? TODO: should we move this to the interface package?
type FactFunc ¶
type FactFunc struct {
Fact Fact
}
FactFunc is a wrapper for the fact interface. It implements the fact interface in terms of Func to reduce the two down to a single mechanism.
func (*FactFunc) Info ¶
func (obj *FactFunc) Info() *interfaces.Info
Info returns some static info about itself.
func (*FactFunc) Init ¶
func (obj *FactFunc) Init(init *interfaces.Init) error
Init runs some startup code for this fact.
type Info ¶
type Info struct { Output *types.Type // output value type (must not change over time!) Err error // did this fact validate? }
Info is a static representation of some information about the fact. It is used for static analysis and type checking. If you break this contract, you might cause a panic.
type Init ¶
type Init struct { Hostname string // uuid for the host //Noop bool Output chan types.Value // Stream must close `output` chan World engine.World Debug bool Logf func(format string, v ...interface{}) }
Init is the structure of values and references which is passed into all facts on initialization.