-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Robert Schuh
committed
Jan 2, 2023
1 parent
d50639d
commit 5f14ba4
Showing
12 changed files
with
235 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 0 additions & 17 deletions
17
src/main/java/io/github/robbilie/nodegreen/FlowConfig.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package io.github.robbilie.nodegreen; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
|
||
import java.util.List; | ||
|
||
public class FlowsJson { | ||
public String rev; | ||
public List<JsonNode> flows; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,39 @@ | ||
package io.github.robbilie.nodegreen; | ||
|
||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
|
||
import java.util.*; | ||
import java.util.stream.Collectors; | ||
|
||
public class RED { | ||
|
||
public static TypeRegistry nodes = new TypeRegistry(); | ||
public static Nodes nodes = new Nodes(); | ||
public static Map<String,Flow> activeFlows = new HashMap<>(); | ||
public static void start(ObjectNode activeFlowConfig) { | ||
RED.stop(); | ||
RED.activeFlows = new HashMap<>(); | ||
RED.activeFlows.put("global", Flow.create(activeFlowConfig)); | ||
for (Iterator<String> it = activeFlowConfig.get("flows").fieldNames(); it.hasNext(); ) { | ||
String id = it.next(); | ||
if (!RED.activeFlows.containsKey(id)) { | ||
RED.activeFlows.put(id, Flow.create(RED.activeFlows.get("global"), activeFlowConfig, (ObjectNode) activeFlowConfig.get("flows").get(id))); | ||
} | ||
} | ||
for (Iterator<String> it = RED.activeFlows.keySet().iterator(); it.hasNext(); ) { | ||
String id = it.next(); | ||
RED.activeFlows.get(id).start(); | ||
} | ||
} | ||
|
||
public static void stop() { | ||
List<String> activeFlowIds = RED.activeFlows.keySet().stream().filter(id -> !id.equals("global")).collect(Collectors.toList()); | ||
if (RED.activeFlows.containsKey("global")) { | ||
activeFlowIds.add("global"); | ||
} | ||
for (Iterator<String> it = activeFlowIds.iterator(); it.hasNext(); ) { | ||
String id = it.next(); | ||
RED.activeFlows.get(id).stop(); | ||
} | ||
RED.activeFlows = new HashMap<>(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/test/java/io/github/robbilie/nodegreen/nodes/AssetsNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package io.github.robbilie.nodegreen.nodes; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import io.github.robbilie.nodegreen.Flow; | ||
import io.github.robbilie.nodegreen.Node; | ||
|
||
import java.util.List; | ||
|
||
public class AssetsNode extends Node { | ||
public List<JsonNode> assets; | ||
public AssetsNode(Flow flow, JsonNode config) { | ||
super(flow, config); | ||
this.assets = config.findValues("assets"); | ||
} | ||
} |
Oops, something went wrong.