当前位置: 首页>>代码示例>>Golang>>正文


Golang client.Client类代码示例

本文整理汇总了Golang中github.com/gocircuit/circuit/client.Client的典型用法代码示例。如果您正苦于以下问题:Golang Client类的具体用法?Golang Client怎么用?Golang Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Client类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
}
开发者ID:hanjin8307,项目名称:circuit,代码行数:12,代码来源:main.go

示例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
}
开发者ID:hanjin8307,项目名称:circuit,代码行数:20,代码来源:main.go

示例3: pickHosts

func pickHosts(c *client.Client, n int) (hosts []client.Anchor) {
	defer func() {
		if recover() != nil {
			fatalf("client connection lost")
		}
	}()
	view := c.View()
	if len(view) == 0 {
		fatalf("no hosts in cluster")
	}
	for len(hosts) < n {
		for _, a := range view {
			if len(hosts) >= n {
				break
			}
			hosts = append(hosts, a)
		}
	}
	return
}
开发者ID:archa347,项目名称:circuit,代码行数:20,代码来源:main.go

示例4: 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)
}
开发者ID:prodigeni,项目名称:circuit,代码行数:26,代码来源:main.go

示例5: pickServer

// pickServer returns the root anchor of a randomly-chosen circuit server in the cluster.
func pickServer(c *client.Client) client.Anchor {
	for _, r := range c.View() {
		return r
	}
	panic(0)
}
开发者ID:hanjin8307,项目名称:circuit,代码行数:7,代码来源:main.go


注:本文中的github.com/gocircuit/circuit/client.Client类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。