1 // Copyright 2020 Chaos Mesh Authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // See the License for the specific language governing permissions and 12 // limitations under the License. 13 14 package node 15 16 type NodePhase string 17 18 const ( 19 Init NodePhase = "Init" 20 WaitingForSchedule NodePhase = "WaitingForSchedule" 21 Running NodePhase = "Running" 22 // It means current node is not changing something, but waiting for some signal. It's still alive. 23 // It's the most common state for most of Node which referenced Template contains duration or deadline. 24 Holding NodePhase = "Holding" 25 Succeed NodePhase = "Succeed" 26 Failed NodePhase = "Failed" 27 WaitingForChild NodePhase = "WaitingForChild" 28 Evaluating NodePhase = "Evaluating" 29 ) 30 31 type Node interface { 32 Name() string 33 NodePhase() NodePhase 34 ParentNodeName() string 35 TemplateName() string 36 } 37 38 // FIXME: remove this interface, it's should belongs to node status 39 type NodeTreeNode interface { 40 Name() string 41 TemplateName() string 42 Children() NodeTreeChildren 43 // Find node by name, might return itself, or find from children nodes recursively 44 FetchNodeByName(nodeName string) (NodeTreeNode, error) 45 } 46 47 type NodeTreeChildren interface { 48 Length() int 49 GetAllChildrenNode() []NodeTreeNode 50 } 51