本文整理汇总了Golang中github.com/burke/zeus/go/processtree.SlaveNode类的典型用法代码示例。如果您正苦于以下问题:Golang SlaveNode类的具体用法?Golang SlaveNode怎么用?Golang SlaveNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SlaveNode类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: iteratePlan
func iteratePlan(tree *processtree.ProcessTree, plan map[string]interface{}, parent *processtree.SlaveNode) {
for name, v := range plan {
if subPlan, ok := v.(map[string]interface{}); ok {
newNode := tree.NewSlaveNode(name, parent)
if parent == nil {
tree.Root = newNode
} else {
parent.Slaves = append(parent.Slaves, newNode)
}
iteratePlan(tree, subPlan, newNode)
} else {
var newNode *processtree.CommandNode
if aliases, ok := v.([]interface{}); ok {
strs := make([]string, len(aliases))
for i, alias := range aliases {
strs[i] = alias.(string)
}
newNode = tree.NewCommandNode(name, strs, parent)
} else if v == nil {
newNode = tree.NewCommandNode(name, nil, parent)
} else {
zerror.ErrorConfigFileInvalidFormat()
}
parent.Commands = append(parent.Commands, newNode)
}
}
}
示例2: drawSubtree
func (s *StatusChart) drawSubtree(node *processtree.SlaveNode, myIndentation, childIndentation string) {
printStateInfo(myIndentation, node.Name, node.State(), false, true)
for i, slave := range node.Slaves {
if i == len(node.Slaves)-1 {
s.drawSubtree(slave, childIndentation+lineL, childIndentation+lineX)
} else {
s.drawSubtree(slave, childIndentation+lineT, childIndentation+lineI)
}
}
}
示例3: bootNewCommand
func bootNewCommand(slaveNode *processtree.SlaveNode, command string, err error) (*unixsocket.Usock, error) {
if err != nil {
return nil, err
}
request := &processtree.CommandRequest{command, make(chan *os.File)}
slaveNode.RequestCommandBoot(request)
commandFile := <-request.Retchan // TODO: don't really want to wait indefinitely.
// defer commandFile.Close() // TODO: can't do this here anymore.
return unixsocket.NewUsockFromFile(commandFile)
}
示例4: bootNewCommand
func bootNewCommand(slaveNode *processtree.SlaveNode, command string, err error) (*unixsocket.Usock, error) {
if err != nil {
return nil, err
}
request := &processtree.CommandRequest{Name: command, Retchan: make(chan *processtree.CommandReply)}
slaveNode.RequestCommandBoot(request)
reply := <-request.Retchan // TODO: don't really want to wait indefinitely.
// defer commandFile.Close() // TODO: can't do this here anymore.
if reply.State == processtree.SCrashed {
return nil, errors.New("Process has crashed")
}
return unixsocket.NewFromFile(reply.File)
}
示例5: logSubtree
func (s *StatusChart) logSubtree(node *processtree.SlaveNode) {
log := theChart.directLogger
printStateInfo("", node.Name, node.State(), true, false)
if len(node.Slaves) > 0 {
log.ColorizedSansNl("{reset}(")
}
for i, slave := range node.Slaves {
if i != 0 {
log.ColorizedSansNl("{reset}, ")
}
s.logSubtree(slave)
}
if len(node.Slaves) > 0 {
log.ColorizedSansNl("{reset})")
}
}