-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
config: validate if config is a DAG #15
Comments
To verify if a configuration is a DAG, one could perform a depth first search and use a stack to detect back edges, which indicate the presence of cycles. func verifyDAG(connectors map[string]connector.Interface) bool {
// Map to keep track of visited nodes
visited := make(map[string]bool)
// Map to track nodes currently in the recursion stack, indicating potential cycles
stack := make(map[string]bool)
// Iterate through all connectors
for _, connector := range connectors {
if !visited[connector.from] {
if isCyclic(connector.from, connectors, visited, stack) {
return false
}
}
}
return true
}
func isCyclic(node string, connectors map[string]connector.Interface, visited, stack map[string]bool) bool {
visited[node] = true
stack[node] = true
// Iterate over all outgoing edges from the current node
for _, connector := range connectors {
if connector.from == node {
if !visited[connector.to] && isCyclic(connector.to, connectors, visited, stack) {
return true
}
// If the node is already in the recursion stack, a cycle is detected
else if stack[connector.to] {
return true
}
}
}
stack[node] = false
return false
} In this algorithm:
However, since the fields I also wanted to provide a test case to illustrate this: I have some ideas for implementing the |
Hi @legosandorigami, thanks for the proposal. Feel free to open a pull request and I will get the patch merged in after a round of review. For http_client and http_endpoint triggers, I propose we discuss it by opening new GitHub issues :) |
The TOML configuration in waymond can have one or many DAGs https://en.wikipedia.org/wiki/Directed_acyclic_graph
We will need to validate this at the startup so that we avoid any cyclic chain of events going on inside waymond.
The text was updated successfully, but these errors were encountered: