Documentation ¶
Index ¶
- Variables
- func FormatIdentity(shape Shape, identifier string) string
- func SetDebugLog()
- func Template(facts facts.Facts, input string, writer io.Writer, customData map[string]any) error
- func TemplateString(facts facts.Facts, input string, customData map[string]any) (string, error)
- type AfterNoder
- type BeforeNoder
- type Context
- type Executor
- type IsCollisioner
- type NeedsExecutioner
- type Node
- type NodeGenerator
- type NodeWrapper
- func (nw NodeWrapper) AfterNodes() []string
- func (nw NodeWrapper) BeforeNodes() []string
- func (nw NodeWrapper) Execute(ctx Context) (any, error)
- func (nw NodeWrapper) Identifier() string
- func (nw NodeWrapper) Identity() (Shape, string)
- func (nw NodeWrapper) IsCollision(other NodeWrapper) error
- func (nw NodeWrapper) NeedsExecution(ctx Context) (bool, error)
- func (nw NodeWrapper) Shape() Shape
- func (nw NodeWrapper) String() string
- func (nw NodeWrapper) Validate() error
- type Queue
- type Shape
- type TContext
- type TemplateData
- type Validator
Constants ¶
This section is empty.
Variables ¶
var (
ErrCyclicalDependencies = fmt.Errorf("tensile: reached iteration limit, nodes have cyclical dependencies")
)
var (
ErrIsCollisionerNotImplemented = fmt.Errorf("nodes do not implement IsCollisioner interface")
)
var ErrNodeIsNil = errors.New("tensile: node in wrapper is nil")
Functions ¶
func FormatIdentity ¶
func SetDebugLog ¶
func SetDebugLog()
SetDebugLog is called from tensiles packages during unit tests to enable debug logging
Types ¶
type AfterNoder ¶
type AfterNoder interface { // AfterNodes lists nodes after which this node must be executed if they exist. AfterNodes() []string }
type BeforeNoder ¶
type BeforeNoder interface { // BeforeNodes lists nodes before which this node must be executed if they exist. BeforeNodes() []string }
type Context ¶
type Context interface { Context() context.Context Logger() *slog.Logger Result(Shape, string) (any, bool, error) Facts() facts.Facts }
TODO context should be initialized by the engine, then passed to node wrappers to fill out with e.g. the correct logger
type IsCollisioner ¶
type IsCollisioner interface { // IsCollision receives another node and should return an error if they // are colliding. // See the Package node for an example. IsCollision(other Node) error }
IsCollisioner is used to detect wether two nodes with the same identity cause a collision.
type NeedsExecutioner ¶
type NodeGenerator ¶
NodeGenerator can return more nodes for a Queue to collect.
This is primarily useful to have a single Noop node that dynamically generates more nodes based on configuration.
type NodeWrapper ¶
NodeWrapper wraps around nodes to provide some common functionality.
func NodeWrap ¶
func NodeWrap(node Node) NodeWrapper
func (NodeWrapper) AfterNodes ¶
func (nw NodeWrapper) AfterNodes() []string
func (NodeWrapper) BeforeNodes ¶
func (nw NodeWrapper) BeforeNodes() []string
func (NodeWrapper) Identifier ¶
func (nw NodeWrapper) Identifier() string
func (NodeWrapper) Identity ¶
func (nw NodeWrapper) Identity() (Shape, string)
func (NodeWrapper) IsCollision ¶
func (nw NodeWrapper) IsCollision(other NodeWrapper) error
func (NodeWrapper) NeedsExecution ¶
func (nw NodeWrapper) NeedsExecution(ctx Context) (bool, error)
func (NodeWrapper) Shape ¶
func (nw NodeWrapper) Shape() Shape
func (NodeWrapper) String ¶
func (nw NodeWrapper) String() string
func (NodeWrapper) Validate ¶
func (nw NodeWrapper) Validate() error
type Shape ¶
type Shape string
Shape is - loosely defined - the type of resource modified by an element. Together with the string returned by a Identitier it defines the identity of an element.
This is meant to prevent clashes when multiple elements modify the same resource.
E.g. consider two elements:
templated := &tensile.Template{ Path: "/path/to/file", ... } lineInFile := &tensile.LineInFile{ Path: "/path/to/target", }
Both would have the identity path[/path/to/target] and would create an error when adding to a queue.
type TContext ¶
type TContext struct {
// contains filtered or unexported fields
}