本文整理汇总了Golang中github.com/pebbe/zmq4.Term函数的典型用法代码示例。如果您正苦于以下问题:Golang Term函数的具体用法?Golang Term怎么用?Golang Term使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Term函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: closePorts
// closePorts closes all active ports and terminates ZMQ context
func closePorts() {
log.Println("Closing ports...")
optionsPort.Close()
inPort.Close()
outPort.Close()
zmq.Term()
}
开发者ID:vishnuvr,项目名称:cascades,代码行数:8,代码来源:main.go
示例2: closePorts
func closePorts() {
optsPort.Close()
tmplPort.Close()
propPort.Close()
if errPort != nil {
errPort.Close()
}
zmq.Term()
}
开发者ID:voxadam,项目名称:cascades-caf,代码行数:9,代码来源:main.go
示例3: closePorts
// closePorts closes all active ports and terminates ZMQ context
func closePorts() {
log.Println("Closing ports...")
optionsPort.Close()
inPort.Close()
if errPort != nil {
errPort.Close()
}
zmq.Term()
}
开发者ID:voxadam,项目名称:cascades-influxdb,代码行数:10,代码来源:main.go
示例4: closePorts
// closePorts closes all active ports and terminates ZMQ context
func closePorts() {
log.Println("Closing ports...")
optionsPort.Close()
if inPort != nil {
inPort.Close()
}
if outPort != nil {
outPort.Close()
}
zmq.Term()
}
开发者ID:voxadam,项目名称:cascades-websocket,代码行数:12,代码来源:main.go
示例5: closePorts
func closePorts() {
requestPort.Close()
failPort.Close()
for _, p := range patternPorts {
p.Close()
}
for _, p := range successPorts {
p.Close()
}
zmq.Term()
}
开发者ID:voxadam,项目名称:cascades-http,代码行数:11,代码来源:main.go
示例6: Close
// Close closes the server, usually deferred upon starting it
func (server *Server) Close() {
// Don't do anything is already closing
if server.closing {
return
}
server.closing = true
glog.Info("zrpc: server closing...")
// Should block until all requests are done
server.conn.Close()
// Terminates the entire zmq context
zmq.Term()
}
开发者ID:gust1n,项目名称:zrpc,代码行数:13,代码来源:server.go
示例7: Close
func (client *Client) Close() error {
glog.Info("zrpc: client closing")
client.mutex.Lock()
if client.closing {
client.mutex.Unlock()
return ErrShutdown
}
client.closing = true
client.mutex.Unlock()
// These should block until all messages returned
client.conn.Close()
client.router.Close()
// Terminate the zmq context
return zmq.Term()
}
开发者ID:gust1n,项目名称:zrpc,代码行数:17,代码来源:client.go
示例8: main
func main() {
info := "greenline: notoriously unreliable\n" +
"https://github.com/formwork-io/greenline\n" +
"This is free software with ABSOLUTELY NO WARRANTY."
fmt.Printf("%s\n--\n", info)
var rails []Rail
if len(os.Args) == 2 {
var err error
rails, err = ReadConfigFile(os.Args[1])
if err != nil {
die(err.Error())
}
} else {
var err error
rails, err = ReadEnvironment()
if err != nil {
die(err.Error())
}
}
pprint("configuring %d rails", len(rails))
socketPairs := make(map[*zmq.Socket]*zmq.Socket)
socketNames := make(map[*zmq.Socket]string)
poller := zmq.NewPoller()
railmsg := "%s protocol %s, %d -> %d"
for _, rail := range rails {
var ingress *zmq.Socket
var egress *zmq.Socket
switch rail.Protocol {
case "broadcast":
ingress, egress = railToPubSub(&rail, poller)
case "request":
ingress, egress = railToRouterDealer(&rail, poller)
default:
die("The protocol %s is not valid.", rail.Protocol)
}
titledProtocol := strings.Title(rail.Protocol)
pprint(railmsg, titledProtocol, rail.Name, rail.Ingress, rail.Egress)
socketPairs[ingress] = egress
socketNames[ingress] = fmt.Sprintf("%s (ingress)", rail.Name)
socketPairs[egress] = ingress
socketNames[egress] = fmt.Sprintf("%s (egress)", rail.Name)
defer ingress.Close()
defer egress.Close()
}
pprint("greenline alive")
exitchan := make(chan os.Signal, 0)
signal.Notify(exitchan, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
go func() {
sig := <-exitchan
out("received %s signal, exiting.\n", sig.String())
os.Exit(0)
}()
reloadchan := make(chan int)
go reloader(reloadchan)
readychan := make(chan bool)
pollchan := make(chan bool)
go func() {
for {
sockets, err := poller.Poll(-1)
if err != nil {
// get EINTR while polling?
if IsEINTR(err) {
// Continue polling; EINTR is normal for us...
continue
// ... with our use of signals.
}
// otherwise shutdown
readychan <- false
break
}
if len(sockets) != 0 {
readychan <- true
}
// wait to poll once msgs processed
<-pollchan
}
}()
pprint("greenline ready")
for {
select {
case reloadOp := <-reloadchan:
if reloadOp&BinReload == BinReload {
pprint("new binary available, restarting greenline")
for key, value := range socketPairs {
key.Close()
value.Close()
}
zmq.Term()
// exec or die
//.........这里部分代码省略.........
开发者ID:formwork-io,项目名称:nakker,代码行数:101,代码来源:main.go
示例9: TestLotsOfIO
func TestLotsOfIO(t *testing.T) {
const (
numSockets = 503
)
defer zmq.Term()
done := make(chan struct{})
for i := 0; i < numSockets; i++ {
addr := fmt.Sprintf("inproc://%d", i)
numMessages := i * 11
if i&1 == 1 {
numMessages -= 1317
}
go func(addr string, numMessages int) {
defer func() {
done <- struct{}{}
}()
s, err := zmq.NewSocket(zmq.PULL)
if err != nil {
t.Fatal(err)
}
defer io.Remove(s)
if err := s.Bind(addr); err != nil {
t.Fatal(err)
}
c := make(chan zmqchan.Data)
if err := io.Add(s, nil, c); err != nil {
t.Fatal(err)
}
for n := 0; n < numMessages; n++ {
m := <-c
ms, err := strconv.Atoi(m.String())
if err != nil {
t.Fatal(err)
}
if ms != n {
t.Fatalf("%d: %d != %d", i, ms, n)
}
}
}(addr, numMessages)
go func(addr string, numMessages int) {
defer func() {
done <- struct{}{}
}()
s, err := zmq.NewSocket(zmq.PUSH)
if err != nil {
t.Fatal(err)
}
defer io.Remove(s)
if err := s.Connect(addr); err != nil {
t.Fatal(err)
}
c := make(chan zmqchan.Data)
defer close(c)
if err := io.Add(s, c, nil); err != nil {
t.Fatal(err)
}
for n := 0; n < numMessages; n++ {
c <- zmqchan.Data{
Bytes: []byte(strconv.Itoa(n)),
}
}
}(addr, numMessages)
}
for i := 0; i < numSockets; i++ {
<-done
}
}
开发者ID:ninchat,项目名称:zmq4chan,代码行数:86,代码来源:io_test.go
注:本文中的github.com/pebbe/zmq4.Term函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论