Documentation ¶
Index ¶
- Variables
- type Action
- type CancelNodeAddAction
- type ErrNodeAddCancelled
- type EventNode
- type Manager
- func (m *Manager) GetEvent(id events.ID) (*EventNode, error)
- func (m *Manager) GetProbe(handle probes.Handle) (*ProbeNode, error)
- func (m *Manager) RemoveEvent(id events.ID) error
- func (m *Manager) SelectEvent(id events.ID) (*EventNode, error)
- func (m *Manager) SubscribeAdd(subscribeType NodeType, onAdd func(node interface{}) []Action)
- func (m *Manager) SubscribeRemove(subscribeType NodeType, onRemove func(node interface{}) []Action)
- func (m *Manager) UnselectEvent(id events.ID) bool
- type NodeType
- type ProbeNode
Constants ¶
This section is empty.
Variables ¶
var ( ErrNodeType = errors.New("unsupported node type") ErrNodeNotFound = errors.New("node not found") )
Functions ¶
This section is empty.
Types ¶
type Action ¶ added in v0.22.0
type Action interface{}
Action is a struct representing a request by a watcher function to interact with the tree.
Actions can perform various tasks, including but not limited to modifying the tree. Utilizing Actions ensures that operations are executed in the proper order, avoiding potential bugs related to operation sequencing. All interactions with the tree which might modify the tree should be carried out through Actions, rather than directly within a watcher's scope.
type CancelNodeAddAction ¶ added in v0.22.0
type CancelNodeAddAction struct {
Reason error
}
CancelNodeAddAction cancels the process of adding a node to the manager.
This method will: 1. Cancel the addition of the specified node. 2. Cancel the addition of all dependent nodes. 3. Remove any dependencies that are no longer referenced by other nodes.
The overall effect is similar to calling RemoveEvent directly on the manager, but with additional safeguards and order of operations to ensure proper cleanup and consistency within the system.
Note: - This action does not prevent other watchers from being notified. - When the node addition is cancelled, event removal watchers will be invoked to allow for cleanup operations.
It is recommended to use CancelNodeAddAction instead of directly calling RemoveEvent to ensure that the cancellation and cleanup processes are handled in the correct order.
func NewCancelNodeAddAction ¶ added in v0.22.0
func NewCancelNodeAddAction(reason error) *CancelNodeAddAction
type ErrNodeAddCancelled ¶ added in v0.22.0
type ErrNodeAddCancelled struct {
Reasons []error
}
ErrNodeAddCancelled is the error produced when cancelling a node add to the manager using the CancelNodeAddAction Action.
func NewErrNodeAddCancelled ¶ added in v0.22.0
func NewErrNodeAddCancelled(reasons []error) *ErrNodeAddCancelled
func (*ErrNodeAddCancelled) AddReason ¶ added in v0.22.0
func (cancelErr *ErrNodeAddCancelled) AddReason(reason error)
func (*ErrNodeAddCancelled) Error ¶ added in v0.22.0
func (cancelErr *ErrNodeAddCancelled) Error() string
type EventNode ¶
type EventNode struct {
// contains filtered or unexported fields
}
EventNode represent an event in the dependencies tree. It should be read-only for other packages, as it is internally managed.
func (*EventNode) GetDependencies ¶
func (en *EventNode) GetDependencies() events.Dependencies
func (*EventNode) GetDependents ¶ added in v0.22.0
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is a management tree for the current dependencies of events. As events can depend on multiple things (e.g events, probes), it manages their connections in the form of a tree. The tree supports watcher functions for adding and removing nodes. The watchers should be used as the way to handle changes in events, probes or any other node type in Tracee.
func NewDependenciesManager ¶
func NewDependenciesManager(dependenciesGetter func(events.ID) events.Dependencies) *Manager
func (*Manager) GetProbe ¶ added in v0.22.0
GetProbe returns the given probe node managed by the Manager
func (*Manager) RemoveEvent ¶
RemoveEvent removes the given event from the management tree. It removes its reference from its dependencies. If these events were added to the tree only as dependencies, they will be removed as well if they are not referenced by any other event anymore and not explicitly selected. It also removes all the events that depend on the given event (as their dependencies are no longer valid). It returns if managed to remove the event, as it might not be present in the tree.
func (*Manager) SelectEvent ¶
SelectEvent adds the given event to the management tree with default dependencies and marks it as explicitly selected. It also recursively adds all events that this event depends on (its dependencies) to the tree. This function has no effect if the event is already added.
func (*Manager) SubscribeAdd ¶
SubscribeAdd adds a watcher function called upon the addition of an event to the tree. Add watcher are called in the order of their subscription.
func (*Manager) SubscribeRemove ¶
SubscribeRemove adds a watcher function called upon the removal of an event from the tree. Remove watchers are called in reverse order of their subscription.
func (*Manager) UnselectEvent ¶
UnselectEvent marks the event as not explicitly selected. If the event is not a dependency of another event, it will be removed from the tree, and its dependencies will be cleaned if they are not referenced or explicitly selected. Returns whether it was removed.
type ProbeNode ¶ added in v0.22.0
type ProbeNode struct {
// contains filtered or unexported fields
}