本文整理汇总了Golang中github.com/gocircuit/circuit/client.Client.Walk方法的典型用法代码示例。如果您正苦于以下问题:Golang Client.Walk方法的具体用法?Golang Client.Walk怎么用?Golang Client.Walk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/gocircuit/circuit/client.Client
的用法示例。
在下文中一共展示了Client.Walk方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: waitFotPayloadDeath
// waitForPayloadDeath blocks until the payload process stored at anchor exits, for whatever reason.
// anchor is the anchor path used by the virus logic.
func waitFotPayloadDeath(c *client.Client, payloadAnchor string) (recov interface{}) {
// defer func() { // catch panics caused by unexpected death of the server hosting the payload
// recov = recover()
// }()
t := c.Walk(client.Split(payloadAnchor)) // Access the process anchor of the currently-running payload of the virus.
t.Get().(client.Proc).Wait() // Wait until the payload process exits.
t.Scrub() // scrub payload anchor from old process element
time.Sleep(2 * time.Second) // Wait a touch to slow down the spin
return
}
示例2: findBackChan
// Create or get back channel
func findBackChan(c *client.Client, isNucleus bool) (backAnchor string, backChan client.Chan) {
var err error
if isNucleus {
// The nucleus does not proceed with execution until it acquires permission
// to send the the virus' back channel.
backAnchor = os.Args[2]
backChan = c.Walk(client.Split(backAnchor)).Get().(client.Chan)
} else {
// Make the back channel
backServer := pickServer(c)
backChan, err = backServer.Walk([]string{"virus", "back"}).MakeChan(3)
if err != nil {
println(err.Error())
os.Exit(1)
}
backAnchor = path.Join("/", backServer.ServerID(), "virus", "back")
}
return
}
示例3: waitFotPayloadDeath
// waitForPayloadDeath blocks until the payload process stored at anchor exits, for whatever reason.
// anchor is the anchor path used by the virus logic.
func waitFotPayloadDeath(c *client.Client, anchor string) {
// catch panics caused by unexpected death of the server hosting the payload
defer func() {
recover()
}()
// Access the process anchor that started this very process and
// remove it to make room for the new one.
// Note that scrubbing a process anchor removes the process element,
// but in no way affects the underlying OS process.
walkToVirus := client.Split(anchor)
c.Walk(append(walkToVirus, "nucleus")).Scrub()
// Access the process anchor of the currently-running payload of the virus.
t := c.Walk(append(walkToVirus, "payload"))
// Wait until the payload process exits.
t.Get().(client.Proc).Wait()
// Remove the anchor of the now-dead payload process.
t.Scrub()
// Wait a touch to prevent spinning, if the payload exits immediately every time it is run.
time.Sleep(time.Second / 2)
}