Documentation ¶
Index ¶
- Variables
- func ExtractImportAndDeclare(componentName string) (importNamespace, customComponentName string)
- type ApplyOptions
- type ArgumentConfigNode
- type BlockNode
- type BuiltinComponentNode
- func (cn *BuiltinComponentNode) Arguments() component.Arguments
- func (cn *BuiltinComponentNode) Block() *ast.BlockStmt
- func (cn *BuiltinComponentNode) Component() component.Component
- func (cn *BuiltinComponentNode) ComponentName() string
- func (cn *BuiltinComponentNode) CurrentHealth() component.Health
- func (cn *BuiltinComponentNode) DebugInfo() interface{}
- func (cn *BuiltinComponentNode) Evaluate(scope *vm.Scope) error
- func (cn *BuiltinComponentNode) Exports() component.Exports
- func (cn *BuiltinComponentNode) ID() ComponentID
- func (cn *BuiltinComponentNode) Label() string
- func (cn *BuiltinComponentNode) ModuleIDs() []string
- func (cn *BuiltinComponentNode) NodeID() string
- func (cn *BuiltinComponentNode) Registration() component.Registration
- func (cn *BuiltinComponentNode) Run(ctx context.Context) error
- func (cn *BuiltinComponentNode) UpdateBlock(b *ast.BlockStmt)
- type ComponentGlobals
- type ComponentID
- type ComponentNode
- type ComponentNodeManager
- type ComponentRegistry
- type ConfigNodeMap
- func (nodeMap *ConfigNodeMap) Append(configNode BlockNode) diag.Diagnostics
- func (nodeMap *ConfigNodeMap) Validate(isInModule bool, args map[string]any) diag.Diagnostics
- func (nodeMap *ConfigNodeMap) ValidateModuleConstraints(isInModule bool) diag.Diagnostics
- func (nodeMap *ConfigNodeMap) ValidateUnsupportedArguments(args map[string]any) diag.Diagnostics
- type CustomComponent
- type CustomComponentNode
- func (cn *CustomComponentNode) Arguments() component.Arguments
- func (cn *CustomComponentNode) Block() *ast.BlockStmt
- func (cn *CustomComponentNode) ComponentName() string
- func (cn *CustomComponentNode) CurrentHealth() component.Health
- func (cn *CustomComponentNode) Evaluate(evalScope *vm.Scope) error
- func (cn *CustomComponentNode) Exports() component.Exports
- func (cn *CustomComponentNode) ID() ComponentID
- func (cn *CustomComponentNode) Label() string
- func (cn *CustomComponentNode) ModuleIDs() []string
- func (cn *CustomComponentNode) NodeID() string
- func (cn *CustomComponentNode) Run(ctx context.Context) error
- func (cn *CustomComponentNode) UpdateBlock(b *ast.BlockStmt)
- type CustomComponentRegistry
- type DeclareNode
- type DefaultComponentRegistry
- type DialFunc
- type ExportConfigNode
- type ImportConfigNode
- func (cn *ImportConfigNode) Block() *ast.BlockStmt
- func (cn *ImportConfigNode) CurrentHealth() component.Health
- func (cn *ImportConfigNode) Equals(other runner.Task) bool
- func (cn *ImportConfigNode) Evaluate(scope *vm.Scope) error
- func (cn *ImportConfigNode) Hash() uint64
- func (cn *ImportConfigNode) ImportConfigNodesChildren() map[string]*ImportConfigNode
- func (cn *ImportConfigNode) ImportedDeclares() map[string]ast.Body
- func (cn *ImportConfigNode) Label() string
- func (cn *ImportConfigNode) NodeID() string
- func (cn *ImportConfigNode) Run(ctx context.Context) error
- type Loader
- func (l *Loader) Apply(options ApplyOptions) diag.Diagnostics
- func (l *Loader) Cleanup(stopWorkerPool bool)
- func (l *Loader) Components() []ComponentNode
- func (l *Loader) EvaluateDependants(ctx context.Context, updatedNodes []*QueuedNode)
- func (l *Loader) Graph() *dag.Graph
- func (l *Loader) Imports() map[string]*ImportConfigNode
- func (l *Loader) OriginalGraph() *dag.Graph
- func (l *Loader) Services() []*ServiceNode
- func (l *Loader) Variables() map[string]interface{}
- type LoaderOptions
- type LoggingConfigNode
- type ModuleController
- type Queue
- type QueuedNode
- type Reference
- type RegistryMap
- type RunnableNode
- type Scheduler
- type ServiceMap
- type ServiceNode
- func (sn *ServiceNode) Block() *ast.BlockStmt
- func (sn *ServiceNode) Definition() service.Definition
- func (sn *ServiceNode) Evaluate(scope *vm.Scope) error
- func (sn *ServiceNode) NodeID() string
- func (sn *ServiceNode) Run(ctx context.Context) error
- func (sn *ServiceNode) Service() service.Service
- func (sn *ServiceNode) UpdateBlock(b *ast.BlockStmt)
- type TracingConfigNode
- type Traversal
Constants ¶
This section is empty.
Variables ¶
var ErrUnevaluated = errors.New("managed component not built")
ErrUnevaluated is returned if BuiltinComponentNode.Run is called before a managed component is built.
Functions ¶
func ExtractImportAndDeclare ¶ added in v0.40.0
ExtractImportAndDeclare extracts an importNamespace and a customComponentName from a componentName. TODO: this function assumes that CustomComponentNames and ImportNamespaces don't contain "." In other words, there are two possible scenarios: - [customComponentName] LABEL -> instance of a local declare - [importNamespace].[customComponentName] LABEL -> instance of an imported declare To address this limitation in the future, we will need to find a different approach to identify the importNamespaces and CustomComponentNames.
Types ¶
type ApplyOptions ¶ added in v0.40.0
type ApplyOptions struct { Args map[string]any // input values of a module (nil for the root module) // TODO: rename ComponentBlocks because it also contains services ComponentBlocks []*ast.BlockStmt // pieces of config that can be used to instantiate builtin components and services ConfigBlocks []*ast.BlockStmt // pieces of config that can be used to instantiate config nodes DeclareBlocks []*ast.BlockStmt // pieces of config that can be used as templates to instantiate custom components // CustomComponentRegistry holds custom component templates. // The definition of a custom component instantiated inside of the loaded config // should be passed via this field if it's not declared or imported in the config. CustomComponentRegistry *CustomComponentRegistry }
ApplyOptions are options that can be provided when loading a new River config.
type ArgumentConfigNode ¶ added in v0.34.0
type ArgumentConfigNode struct {
// contains filtered or unexported fields
}
func NewArgumentConfigNode ¶ added in v0.34.0
func NewArgumentConfigNode(block *ast.BlockStmt, globals ComponentGlobals) *ArgumentConfigNode
NewArgumentConfigNode creates a new ArgumentConfigNode from an initial ast.BlockStmt. The underlying config isn't applied until Evaluate is called.
func (*ArgumentConfigNode) Block ¶ added in v0.34.0
func (cn *ArgumentConfigNode) Block() *ast.BlockStmt
Block implements BlockNode and returns the current block of the managed config node.
func (*ArgumentConfigNode) Default ¶ added in v0.34.0
func (cn *ArgumentConfigNode) Default() any
func (*ArgumentConfigNode) Evaluate ¶ added in v0.34.0
func (cn *ArgumentConfigNode) Evaluate(scope *vm.Scope) error
Evaluate implements BlockNode and updates the arguments for the managed config block by re-evaluating its River block with the provided scope. The managed config block will be built the first time Evaluate is called.
Evaluate will return an error if the River block cannot be evaluated or if decoding to arguments fails.
func (*ArgumentConfigNode) Label ¶ added in v0.34.0
func (cn *ArgumentConfigNode) Label() string
func (*ArgumentConfigNode) NodeID ¶ added in v0.34.0
func (cn *ArgumentConfigNode) NodeID() string
NodeID implements dag.Node and returns the unique ID for the config node.
func (*ArgumentConfigNode) Optional ¶ added in v0.34.0
func (cn *ArgumentConfigNode) Optional() bool
type BlockNode ¶ added in v0.33.0
type BlockNode interface { dag.Node // Block returns the current block of the managed config node. Block() *ast.BlockStmt // Evaluate updates the arguments for the managed component // by re-evaluating its River block with the provided scope. The managed component // will be built the first time Evaluate is called. // // Evaluate will return an error if the River block cannot be evaluated or if // decoding to arguments fails. Evaluate(scope *vm.Scope) error }
BlockNode is a node in the DAG which manages a River block and can be evaluated.
func NewConfigNode ¶ added in v0.29.0
func NewConfigNode(block *ast.BlockStmt, globals ComponentGlobals) (BlockNode, diag.Diagnostics)
NewConfigNode creates a new ConfigNode from an initial ast.BlockStmt. The underlying config isn't applied until Evaluate is called.
type BuiltinComponentNode ¶ added in v0.40.0
type BuiltinComponentNode struct { OnBlockNodeUpdate func(cn BlockNode) // Informs controller that we need to reevaluate // contains filtered or unexported fields }
BuiltinComponentNode is a controller node which manages a builtin component.
BuiltinComponentNode manages the underlying component and caches its current arguments and exports. BuiltinComponentNode manages the arguments for the component from a River block.
func NewBuiltinComponentNode ¶ added in v0.40.0
func NewBuiltinComponentNode(globals ComponentGlobals, reg component.Registration, b *ast.BlockStmt) *BuiltinComponentNode
NewBuiltinComponentNode creates a new BuiltinComponentNode from an initial ast.BlockStmt. The underlying managed component isn't created until Evaluate is called.
func (*BuiltinComponentNode) Arguments ¶ added in v0.40.0
func (cn *BuiltinComponentNode) Arguments() component.Arguments
Arguments returns the current arguments of the managed component.
func (*BuiltinComponentNode) Block ¶ added in v0.40.0
func (cn *BuiltinComponentNode) Block() *ast.BlockStmt
Block implements BlockNode and returns the current block of the managed component.
func (*BuiltinComponentNode) Component ¶ added in v0.40.0
func (cn *BuiltinComponentNode) Component() component.Component
Component returns the instance of the managed component. Component may be nil if the BuiltinComponentNode has not been successfully evaluated yet.
func (*BuiltinComponentNode) ComponentName ¶ added in v0.40.0
func (cn *BuiltinComponentNode) ComponentName() string
ComponentName returns the component's type, i.e. `local.file.test` returns `local.file`.
func (*BuiltinComponentNode) CurrentHealth ¶ added in v0.40.0
func (cn *BuiltinComponentNode) CurrentHealth() component.Health
CurrentHealth returns the current health of the BuiltinComponentNode.
The health of a BuiltinComponentNode is determined by combining:
- Health from the call to Run().
- Health from the last call to Evaluate().
- Health reported from the component.
func (*BuiltinComponentNode) DebugInfo ¶ added in v0.40.0
func (cn *BuiltinComponentNode) DebugInfo() interface{}
DebugInfo returns debugging information from the managed component (if any).
func (*BuiltinComponentNode) Evaluate ¶ added in v0.40.0
func (cn *BuiltinComponentNode) Evaluate(scope *vm.Scope) error
Evaluate implements BlockNode and updates the arguments for the managed component by re-evaluating its River block with the provided scope. The managed component will be built the first time Evaluate is called.
Evaluate will return an error if the River block cannot be evaluated or if decoding to arguments fails.
func (*BuiltinComponentNode) Exports ¶ added in v0.40.0
func (cn *BuiltinComponentNode) Exports() component.Exports
Exports returns the current set of exports from the managed component. Exports returns nil if the managed component does not have exports.
func (*BuiltinComponentNode) ID ¶ added in v0.40.0
func (cn *BuiltinComponentNode) ID() ComponentID
ID returns the component ID of the managed component from its River block.
func (*BuiltinComponentNode) Label ¶ added in v0.40.0
func (cn *BuiltinComponentNode) Label() string
Label returns the label for the block or "" if none was specified.
func (*BuiltinComponentNode) ModuleIDs ¶ added in v0.40.0
func (cn *BuiltinComponentNode) ModuleIDs() []string
ModuleIDs returns the current list of modules that this component is managing.
func (*BuiltinComponentNode) NodeID ¶ added in v0.40.0
func (cn *BuiltinComponentNode) NodeID() string
NodeID implements dag.Node and returns the unique ID for this node. The NodeID is the string representation of the component's ID from its River block.
func (*BuiltinComponentNode) Registration ¶ added in v0.40.0
func (cn *BuiltinComponentNode) Registration() component.Registration
Registration returns the original registration of the component.
func (*BuiltinComponentNode) Run ¶ added in v0.40.0
func (cn *BuiltinComponentNode) Run(ctx context.Context) error
Run runs the managed component in the calling goroutine until ctx is canceled. Evaluate must have been called at least once without returning an error before calling Run.
Run will immediately return ErrUnevaluated if Evaluate has never been called successfully. Otherwise, Run will return nil.
func (*BuiltinComponentNode) UpdateBlock ¶ added in v0.40.0
func (cn *BuiltinComponentNode) UpdateBlock(b *ast.BlockStmt)
UpdateBlock updates the River block used to construct arguments for the managed component. The new block isn't used until the next time Evaluate is invoked.
UpdateBlock will panic if the block does not match the component ID of the BuiltinComponentNode.
type ComponentGlobals ¶
type ComponentGlobals struct { Logger *logging.Logger // Logger shared between all managed components. TraceProvider trace.TracerProvider // Tracer shared between all managed components. DataPath string // Shared directory where component data may be stored OnBlockNodeUpdate func(cn BlockNode) // Informs controller that we need to reevaluate OnExportsChange func(exports map[string]any) // Invoked when the managed component updated its exports Registerer prometheus.Registerer // Registerer for serving agent and component metrics ControllerID string // ID of controller. NewModuleController func(id string) ModuleController // Func to generate a module controller. GetServiceData func(name string) (interface{}, error) // Get data for a service. }
ComponentGlobals are used by BuiltinComponentNodes to build managed components. All BuiltinComponentNodes should use the same ComponentGlobals.
type ComponentID ¶
type ComponentID []string
ComponentID is a fully-qualified name of a component. Each element in ComponentID corresponds to a fragment of the period-delimited string; "remote.http.example" is ComponentID{"remote", "http", "example"}.
func BlockComponentID ¶
func BlockComponentID(b *ast.BlockStmt) ComponentID
BlockComponentID returns the ComponentID specified by an River block.
func (ComponentID) Equals ¶
func (id ComponentID) Equals(other ComponentID) bool
Equals returns true if id == other.
func (ComponentID) String ¶
func (id ComponentID) String() string
String returns the string representation of a component ID.
type ComponentNode ¶
type ComponentNode interface { RunnableNode // CurrentHealth returns the current health of the component. CurrentHealth() component.Health // Arguments returns the current arguments of the managed component. Arguments() component.Arguments // Exports returns the current set of exports from the managed component. Exports() component.Exports // Label returns the component label. Label() string // ComponentName returns the name of the component. ComponentName() string // ID returns the component ID of the managed component from its River block. ID() ComponentID // UpdateBlock updates the River block used to construct arguments for the managed component. UpdateBlock(b *ast.BlockStmt) // ModuleIDs returns the current list of modules managed by the component. ModuleIDs() []string }
ComponentNode is a generic representation of a Flow component.
type ComponentNodeManager ¶ added in v0.40.0
type ComponentNodeManager struct {
// contains filtered or unexported fields
}
ComponentNodeManager is responsible for creating new component nodes and obtaining the necessary information to run them.
func NewComponentNodeManager ¶ added in v0.40.0
func NewComponentNodeManager(globals ComponentGlobals, componentReg ComponentRegistry) *ComponentNodeManager
NewComponentNodeManager creates a new ComponentNodeManager without custom component registry.
type ComponentRegistry ¶ added in v0.36.0
type ComponentRegistry interface { // Get looks up a component by name. Get(name string) (component.Registration, bool) }
ComponentRegistry is a collection of registered components.
type ConfigNodeMap ¶ added in v0.34.0
type ConfigNodeMap struct {
// contains filtered or unexported fields
}
ConfigNodeMap represents the config BlockNodes in their explicit types. This is helpful when validating node conditions specific to config node types.
func NewConfigNodeMap ¶ added in v0.34.0
func NewConfigNodeMap() *ConfigNodeMap
NewConfigNodeMap will create an initial ConfigNodeMap. Append must be called to populate NewConfigNodeMap.
func (*ConfigNodeMap) Append ¶ added in v0.34.0
func (nodeMap *ConfigNodeMap) Append(configNode BlockNode) diag.Diagnostics
Append will add a config node to the ConfigNodeMap. This will overwrite values on the ConfigNodeMap that are matched and previously set.
func (*ConfigNodeMap) Validate ¶ added in v0.34.0
func (nodeMap *ConfigNodeMap) Validate(isInModule bool, args map[string]any) diag.Diagnostics
Validate wraps all validators for ConfigNodeMap.
func (*ConfigNodeMap) ValidateModuleConstraints ¶ added in v0.34.0
func (nodeMap *ConfigNodeMap) ValidateModuleConstraints(isInModule bool) diag.Diagnostics
ValidateModuleConstraints will make sure config blocks with module constraints get followed.
func (*ConfigNodeMap) ValidateUnsupportedArguments ¶ added in v0.34.0
func (nodeMap *ConfigNodeMap) ValidateUnsupportedArguments(args map[string]any) diag.Diagnostics
ValidateUnsupportedArguments will validate each provided argument is supported in the config.
type CustomComponent ¶ added in v0.40.0
type CustomComponent interface { // LoadBody loads a River AST body into the CustomComponent. LoadBody can be called // multiple times, and called prior to [CustomComponent.Run]. // customComponentRegistry provides custom component definitions for the loaded config. LoadBody(body ast.Body, args map[string]any, customComponentRegistry *CustomComponentRegistry) error // Run starts the CustomComponent. No components within the CustomComponent // will be run until Run is called. // // Run blocks until the provided context is canceled. The ID of a CustomComponent as defined in // ModuleController.NewCustomComponent will not be released until Run returns. Run(context.Context) error }
CustomComponent is a controller for running components within a CustomComponent.
type CustomComponentNode ¶ added in v0.40.0
type CustomComponentNode struct { OnBlockNodeUpdate func(cn BlockNode) // Informs controller that we need to reevaluate // contains filtered or unexported fields }
CustomComponentNode is a controller node which manages a custom component.
CustomComponentNode manages the underlying custom component and caches its current arguments and exports.
func NewCustomComponentNode ¶ added in v0.40.0
func NewCustomComponentNode(globals ComponentGlobals, b *ast.BlockStmt, getConfig getCustomComponentConfig) *CustomComponentNode
NewCustomComponentNode creates a new CustomComponentNode from an initial ast.BlockStmt. The underlying managed custom component isn't created until Evaluate is called.
func (*CustomComponentNode) Arguments ¶ added in v0.40.0
func (cn *CustomComponentNode) Arguments() component.Arguments
Arguments returns the current arguments of the managed custom component.
func (*CustomComponentNode) Block ¶ added in v0.40.0
func (cn *CustomComponentNode) Block() *ast.BlockStmt
Block implements BlockNode and returns the current block of the managed custom component.
func (*CustomComponentNode) ComponentName ¶ added in v0.40.0
func (cn *CustomComponentNode) ComponentName() string
ComponentName returns the name of the component.
func (*CustomComponentNode) CurrentHealth ¶ added in v0.40.0
func (cn *CustomComponentNode) CurrentHealth() component.Health
CurrentHealth returns the current health of the CustomComponentNode.
The health of a CustomComponentNode is determined by combining:
- Health from the call to Run().
- Health from the last call to Evaluate().
func (*CustomComponentNode) Evaluate ¶ added in v0.40.0
func (cn *CustomComponentNode) Evaluate(evalScope *vm.Scope) error
Evaluate implements BlockNode and updates the arguments by re-evaluating its River block with the provided scope and the custom component by retrieving the component definition from the corresponding import or declare node. The managed custom component will be built the first time Evaluate is called.
Evaluate will return an error if the River block cannot be evaluated, if decoding to arguments fails or if the custom component definition cannot be retrieved.
func (*CustomComponentNode) Exports ¶ added in v0.40.0
func (cn *CustomComponentNode) Exports() component.Exports
Exports returns the current set of exports from the managed custom component. Exports returns nil if the managed custom component does not have exports.
func (*CustomComponentNode) ID ¶ added in v0.40.0
func (cn *CustomComponentNode) ID() ComponentID
ID returns the component ID of the managed component from its River block.
func (*CustomComponentNode) Label ¶ added in v0.40.0
func (cn *CustomComponentNode) Label() string
Label returns the label for the block or "" if none was specified.
func (*CustomComponentNode) ModuleIDs ¶ added in v0.40.0
func (cn *CustomComponentNode) ModuleIDs() []string
TODO: currently used by the component provider to access the components running within the custom components. Change it when getting rid of old modules.
func (*CustomComponentNode) NodeID ¶ added in v0.40.0
func (cn *CustomComponentNode) NodeID() string
NodeID implements dag.Node and returns the unique ID for this node. The NodeID is the string representation of the component's ID from its River block.
func (*CustomComponentNode) Run ¶ added in v0.40.0
func (cn *CustomComponentNode) Run(ctx context.Context) error
func (*CustomComponentNode) UpdateBlock ¶ added in v0.40.0
func (cn *CustomComponentNode) UpdateBlock(b *ast.BlockStmt)
UpdateBlock updates the River block used to construct arguments for the managed component. The new block isn't used until the next time Evaluate is invoked.
UpdateBlock will panic if the block does not match the component ID of the CustomComponentNode.
type CustomComponentRegistry ¶ added in v0.40.0
type CustomComponentRegistry struct {
// contains filtered or unexported fields
}
CustomComponentRegistry holds custom component definitions that are available in the context. The definitions are either imported, declared locally, or declared in a parent registry. Imported definitions are stored inside of the corresponding import registry.
func NewCustomComponentRegistry ¶ added in v0.40.0
func NewCustomComponentRegistry(parent *CustomComponentRegistry) *CustomComponentRegistry
NewCustomComponentRegistry creates a new CustomComponentRegistry with a parent. parent can be nil.
type DeclareNode ¶ added in v0.40.0
type DeclareNode struct {
// contains filtered or unexported fields
}
DeclareNode represents a declare block in the DAG.
func NewDeclareNode ¶ added in v0.40.0
func NewDeclareNode(block *ast.BlockStmt) *DeclareNode
NewDeclareNode creates a new declare node with a content which will be loaded by custom components.
func (*DeclareNode) Block ¶ added in v0.40.0
func (cn *DeclareNode) Block() *ast.BlockStmt
Block implements BlockNode and returns the current block of the managed config node.
func (*DeclareNode) Evaluate ¶ added in v0.40.0
func (cn *DeclareNode) Evaluate(scope *vm.Scope) error
Evaluate does nothing for this node.
func (*DeclareNode) Label ¶ added in v0.40.0
func (cn *DeclareNode) Label() string
Label returns the label of the block.
func (*DeclareNode) NodeID ¶ added in v0.40.0
func (cn *DeclareNode) NodeID() string
NodeID implements dag.Node and returns the unique ID for the config node.
type DefaultComponentRegistry ¶ added in v0.36.0
type DefaultComponentRegistry struct{}
DefaultComponentRegistry is the default ComponentRegistry which gets components registered to github.com/grafana/agent/component.
func (DefaultComponentRegistry) Get ¶ added in v0.36.0
func (reg DefaultComponentRegistry) Get(name string) (component.Registration, bool)
Get retrieves a component using component.Get.
type ExportConfigNode ¶ added in v0.33.0
type ExportConfigNode struct {
// contains filtered or unexported fields
}
func NewExportConfigNode ¶ added in v0.33.0
func NewExportConfigNode(block *ast.BlockStmt, globals ComponentGlobals) *ExportConfigNode
NewExportConfigNode creates a new ExportConfigNode from an initial ast.BlockStmt. The underlying config isn't applied until Evaluate is called.
func (*ExportConfigNode) Block ¶ added in v0.33.0
func (cn *ExportConfigNode) Block() *ast.BlockStmt
Block implements BlockNode and returns the current block of the managed config node.
func (*ExportConfigNode) Evaluate ¶ added in v0.33.0
func (cn *ExportConfigNode) Evaluate(scope *vm.Scope) error
Evaluate implements BlockNode and updates the arguments for the managed config block by re-evaluating its River block with the provided scope. The managed config block will be built the first time Evaluate is called.
Evaluate will return an error if the River block cannot be evaluated or if decoding to arguments fails.
func (*ExportConfigNode) Label ¶ added in v0.34.0
func (cn *ExportConfigNode) Label() string
func (*ExportConfigNode) NodeID ¶ added in v0.33.0
func (cn *ExportConfigNode) NodeID() string
NodeID implements dag.Node and returns the unique ID for the config node.
func (*ExportConfigNode) Value ¶ added in v0.34.0
func (cn *ExportConfigNode) Value() any
Value returns the value of the export.
type ImportConfigNode ¶ added in v0.40.0
type ImportConfigNode struct { OnBlockNodeUpdate func(cn BlockNode) // notifies the controller or the parent for reevaluation // contains filtered or unexported fields }
ImportConfigNode imports declare and import blocks via a managed import source. The imported declare are stored in importedDeclares. For every imported import block, the ImportConfigNode will create ImportConfigNode children. The children are evaluated and ran by the parent. When an ImportConfigNode receives new content from its source, it updates its importedDeclares and recreates its children. Then an update call is propagated to the root ImportConfigNode to inform the controller for reevaluation.
func NewImportConfigNode ¶ added in v0.40.0
func NewImportConfigNode(block *ast.BlockStmt, globals ComponentGlobals, sourceType importsource.SourceType) *ImportConfigNode
NewImportConfigNode creates a new ImportConfigNode from an initial ast.BlockStmt. The underlying config isn't applied until Evaluate is called.
func (*ImportConfigNode) Block ¶ added in v0.40.0
func (cn *ImportConfigNode) Block() *ast.BlockStmt
Block implements BlockNode and returns the current block of the managed config node.
func (*ImportConfigNode) CurrentHealth ¶ added in v0.40.0
func (cn *ImportConfigNode) CurrentHealth() component.Health
CurrentHealth returns the current health of the ImportConfigNode.
The health of a ImportConfigNode is determined by combining:
- Health from the call to Run().
- Health from the last call to Evaluate().
- Health from the last call to OnContentChange().
- Health reported from the source.
- Health reported from the nested imports.
func (*ImportConfigNode) Equals ¶ added in v0.40.0
func (cn *ImportConfigNode) Equals(other runner.Task) bool
We don't want to reuse previous running tasks. On every updates, the previous workers should be stopped and new ones should spawn.
func (*ImportConfigNode) Evaluate ¶ added in v0.40.0
func (cn *ImportConfigNode) Evaluate(scope *vm.Scope) error
Evaluate implements BlockNode and evaluates the import source.
func (*ImportConfigNode) Hash ¶ added in v0.40.0
func (cn *ImportConfigNode) Hash() uint64
func (*ImportConfigNode) ImportConfigNodesChildren ¶ added in v0.40.0
func (cn *ImportConfigNode) ImportConfigNodesChildren() map[string]*ImportConfigNode
ImportConfigNodesChildren returns the ImportConfigNodesChildren of this ImportConfigNode.
func (*ImportConfigNode) ImportedDeclares ¶ added in v0.40.0
func (cn *ImportConfigNode) ImportedDeclares() map[string]ast.Body
ImportedDeclares returns all declare blocks that it imported.
func (*ImportConfigNode) Label ¶ added in v0.40.0
func (cn *ImportConfigNode) Label() string
func (*ImportConfigNode) NodeID ¶ added in v0.40.0
func (cn *ImportConfigNode) NodeID() string
NodeID implements dag.Node and returns the unique ID for the config node.
func (*ImportConfigNode) Run ¶ added in v0.40.0
func (cn *ImportConfigNode) Run(ctx context.Context) error
Run runs the managed source and the import children until ctx is canceled. Evaluate must have been called at least once without returning an error before calling Run.
Run will immediately return ErrUnevaluated if Evaluate has never been called successfully. Otherwise, Run will return nil.
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
The Loader builds and evaluates ComponentNodes from River blocks.
func NewLoader ¶
func NewLoader(opts LoaderOptions) *Loader
NewLoader creates a new Loader. Components built by the Loader will be built with co for their options.
func (*Loader) Apply ¶
func (l *Loader) Apply(options ApplyOptions) diag.Diagnostics
Apply loads a new set of components into the Loader. Apply will drop any previously loaded component which is not described in the set of River blocks.
Apply will reuse existing components if there is an existing component which matches the component ID specified by any of the provided River blocks. Reused components will be updated to point at the new River block.
Apply will perform an evaluation of all loaded components before returning. The provided parentContext can be used to provide global variables and functions to components. A child context will be constructed from the parent to expose values of other components.
func (*Loader) Cleanup ¶ added in v0.35.0
Cleanup unregisters any existing metrics and optionally stops the worker pool.
func (*Loader) Components ¶
func (l *Loader) Components() []ComponentNode
Components returns the current set of loaded components.
func (*Loader) EvaluateDependants ¶ added in v0.39.0
func (l *Loader) EvaluateDependants(ctx context.Context, updatedNodes []*QueuedNode)
EvaluateDependants sends nodes which depend directly on nodes in updatedNodes for evaluation to the workerPool. It should be called whenever nodes update their exports. It is beneficial to call EvaluateDependants with a batch of nodes, as it will enqueue the entire batch before the worker pool starts to evaluate them, resulting in smaller number of total evaluations when node updates are frequent. If the worker pool's queue is full, EvaluateDependants will retry with a backoff until it succeeds or until the ctx is cancelled.
func (*Loader) Imports ¶ added in v0.40.0
func (l *Loader) Imports() map[string]*ImportConfigNode
Imports returns the current set of import nodes.
func (*Loader) OriginalGraph ¶ added in v0.28.0
OriginalGraph returns a copy of the graph before Reduce was called. This can be used if you want to show a UI of the original graph before the reduce function was called.
func (*Loader) Services ¶ added in v0.36.0
func (l *Loader) Services() []*ServiceNode
Services returns the current set of service nodes.
type LoaderOptions ¶ added in v0.36.0
type LoaderOptions struct { // ComponentGlobals contains data to use when creating components. ComponentGlobals ComponentGlobals Services []service.Service // Services to load into the DAG. Host service.Host // Service host (when running services). ComponentRegistry ComponentRegistry // Registry to search for components. WorkerPool worker.Pool // Worker pool to use for async tasks. }
LoaderOptions holds options for creating a Loader.
type LoggingConfigNode ¶ added in v0.33.0
type LoggingConfigNode struct {
// contains filtered or unexported fields
}
func NewDefaultLoggingConfigNode ¶ added in v0.33.0
func NewDefaultLoggingConfigNode(globals ComponentGlobals) *LoggingConfigNode
NewDefaultLoggingConfigNode creates a new LoggingConfigNode with nil block and eval. This will force evaluate to use the default logging options for this node.
func NewLoggingConfigNode ¶ added in v0.33.0
func NewLoggingConfigNode(block *ast.BlockStmt, globals ComponentGlobals) *LoggingConfigNode
NewLoggingConfigNode creates a new LoggingConfigNode from an initial ast.BlockStmt. The underlying config isn't applied until Evaluate is called.
func (*LoggingConfigNode) Block ¶ added in v0.33.0
func (cn *LoggingConfigNode) Block() *ast.BlockStmt
Block implements BlockNode and returns the current block of the managed config node.
func (*LoggingConfigNode) Evaluate ¶ added in v0.33.0
func (cn *LoggingConfigNode) Evaluate(scope *vm.Scope) error
Evaluate implements BlockNode and updates the arguments for the managed config block by re-evaluating its River block with the provided scope. The managed config block will be built the first time Evaluate is called.
Evaluate will return an error if the River block cannot be evaluated or if decoding to arguments fails.
func (*LoggingConfigNode) NodeID ¶ added in v0.33.0
func (cn *LoggingConfigNode) NodeID() string
NodeID implements dag.Node and returns the unique ID for the config node.
type ModuleController ¶ added in v0.35.0
type ModuleController interface { component.ModuleController // ModuleIDs returns the list of managed modules in unspecified order. ModuleIDs() []string // Creates a new custom component. NewCustomComponent(id string, export component.ExportFunc) (CustomComponent, error) }
ModuleController is a lower-level interface for module controllers which allows probing for the list of managed modules.
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue is a thread-safe, insertion-ordered set of nodes.
Queue is intended for tracking nodes that have been updated for later reevaluation.
func (*Queue) Chan ¶
func (q *Queue) Chan() <-chan struct{}
Chan returns a channel which is written to when the queue is non-empty.
func (*Queue) DequeueAll ¶ added in v0.37.0
func (q *Queue) DequeueAll() []*QueuedNode
DequeueAll removes all BlockNode from the queue and returns them.
func (*Queue) Enqueue ¶
func (q *Queue) Enqueue(c *QueuedNode)
Enqueue inserts a new BlockNode into the Queue. Enqueue is a no-op if the BlockNode is already in the Queue.
type QueuedNode ¶ added in v0.40.0
type Reference ¶
type Reference struct { Target BlockNode // BlockNode being referenced // Traversal describes which nested field relative to Target is being // accessed. Traversal Traversal }
Reference describes an River expression reference to a BlockNode.
func ComponentReferences ¶
ComponentReferences returns the list of references a component is making to other components.
type RegistryMap ¶ added in v0.36.0
type RegistryMap map[string]component.Registration
RegistryMap is a map which implements ComponentRegistry.
func (RegistryMap) Get ¶ added in v0.36.0
func (m RegistryMap) Get(name string) (component.Registration, bool)
Get retrieves a component using component.Get.
type RunnableNode ¶
RunnableNode is any BlockNode which can also be run.
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler runs components.
func NewScheduler ¶
func NewScheduler() *Scheduler
NewScheduler creates a new Scheduler. Call Synchronize to manage the set of components which are running.
Call Close to stop the Scheduler and all running components.
func (*Scheduler) Close ¶
Close stops the Scheduler and returns after all running goroutines have exited.
func (*Scheduler) Synchronize ¶
func (s *Scheduler) Synchronize(rr []RunnableNode) error
Synchronize synchronizes the running components to those defined by rr.
New RunnableNodes will be launched as new goroutines. RunnableNodes already managed by Scheduler will be kept running, while running RunnableNodes that are not in rr will be shut down and removed.
Existing components will be restarted if they stopped since the previous call to Synchronize.
type ServiceMap ¶ added in v0.36.0
ServiceMap is a map of service name to services.
func NewServiceMap ¶ added in v0.36.0
func NewServiceMap(services []service.Service) ServiceMap
NewServiceMap creates a ServiceMap from a slice of services.
func (ServiceMap) FilterByName ¶ added in v0.36.0
func (sm ServiceMap) FilterByName(keepNames []string) ServiceMap
FilterByName creates a new ServiceMap where services that are not defined in keepNames are removed.
func (ServiceMap) Get ¶ added in v0.36.0
func (sm ServiceMap) Get(name string) (svc service.Service, found bool)
Get looks up a service by name.
func (ServiceMap) List ¶ added in v0.36.0
func (sm ServiceMap) List() []service.Service
List returns a slice of all the services.
type ServiceNode ¶ added in v0.36.0
type ServiceNode struct {
// contains filtered or unexported fields
}
ServiceNode is a Flow DAG node which represents a running service.
func NewServiceNode ¶ added in v0.36.0
func NewServiceNode(host service.Host, svc service.Service) *ServiceNode
NewServiceNode creates a new instance of a ServiceNode from an instance of a Service. The provided host is used when running the service.
func (*ServiceNode) Block ¶ added in v0.36.0
func (sn *ServiceNode) Block() *ast.BlockStmt
Block implements BlockNode. It returns nil, since ServiceNodes don't have associated configs.
func (*ServiceNode) Definition ¶ added in v0.36.0
func (sn *ServiceNode) Definition() service.Definition
Definition returns the service definition associated with the node.
func (*ServiceNode) Evaluate ¶ added in v0.36.0
func (sn *ServiceNode) Evaluate(scope *vm.Scope) error
Evaluate implements BlockNode, evaluating the configuration for a service. Evalute returns an error if the service doesn't support being configured and the ServiceNode has an associated block from a call to UpdateBlock.
func (*ServiceNode) NodeID ¶ added in v0.36.0
func (sn *ServiceNode) NodeID() string
NodeID returns the ID of the ServiceNode, which is equal to the service's name.
func (*ServiceNode) Service ¶ added in v0.36.0
func (sn *ServiceNode) Service() service.Service
Service returns the service instance associated with the node.
func (*ServiceNode) UpdateBlock ¶ added in v0.36.0
func (sn *ServiceNode) UpdateBlock(b *ast.BlockStmt)
UpdateBlock updates the River block used to construct arguments for the service. The new block isn't used until the next time Evaluate is called.
UpdateBlock will panic if the block does not match the ID of the ServiceNode.
Call UpdateBlock with a nil block to remove the block associated with the ServiceNode.
type TracingConfigNode ¶ added in v0.33.0
type TracingConfigNode struct {
// contains filtered or unexported fields
}
func NewDefaulTracingConfigNode ¶ added in v0.33.0
func NewDefaulTracingConfigNode(globals ComponentGlobals) *TracingConfigNode
NewDefaulTracingConfigNode creates a new TracingConfigNode with nil block and eval. This will force evaluate to use the default tracing options for this node.
func NewTracingConfigNode ¶ added in v0.33.0
func NewTracingConfigNode(block *ast.BlockStmt, globals ComponentGlobals) *TracingConfigNode
NewTracingConfigNode creates a new TracingConfigNode from an initial ast.BlockStmt. The underlying config isn't applied until Evaluate is called.
func (*TracingConfigNode) Block ¶ added in v0.33.0
func (cn *TracingConfigNode) Block() *ast.BlockStmt
Block implements BlockNode and returns the current block of the managed config node.
func (*TracingConfigNode) Evaluate ¶ added in v0.33.0
func (cn *TracingConfigNode) Evaluate(scope *vm.Scope) error
Evaluate implements BlockNode and updates the arguments for the managed config block by re-evaluating its River block with the provided scope. The managed config block will be built the first time Evaluate is called.
Evaluate will return an error if the River block cannot be evaluated or if decoding to arguments fails.
func (*TracingConfigNode) NodeID ¶ added in v0.33.0
func (cn *TracingConfigNode) NodeID() string
NodeID implements dag.Node and returns the unique ID for the config node.
Source Files ¶
- block_node.go
- component_node.go
- component_node_manager.go
- component_references.go
- component_registry.go
- custom_component_registry.go
- loader.go
- metrics.go
- module.go
- node_builtin_component.go
- node_config.go
- node_config_argument.go
- node_config_export.go
- node_config_import.go
- node_config_logging.go
- node_config_tracing.go
- node_custom_component.go
- node_declare.go
- node_service.go
- queue.go
- scheduler.go
- service_map.go
- value_cache.go