本文整理匯總了Golang中github.com/cascades-fbp/cascades/components/utils.CreateInputPort函數的典型用法代碼示例。如果您正苦於以下問題:Golang CreateInputPort函數的具體用法?Golang CreateInputPort怎麽用?Golang CreateInputPort使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CreateInputPort函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: openPorts
// openPorts create ZMQ sockets and start socket monitoring loops
func openPorts() {
optionsPort, err = utils.CreateInputPort("tcp/server.options", *optionsEndpoint, nil)
utils.AssertError(err)
inPort, err = utils.CreateInputPort("tcp/server.in", *inputEndpoint, inCh)
utils.AssertError(err)
}
示例2: openPorts
// openPorts create ZMQ sockets and start socket monitoring loops
func openPorts() {
tplPort, err = utils.CreateInputPort("template.tpl", *tplEndpoint, nil)
utils.AssertError(err)
inPort, err = utils.CreateInputPort("template.in", *inputEndpoint, inCh)
utils.AssertError(err)
outPort, err = utils.CreateOutputPort("template.out", *outputEndpoint, outCh)
utils.AssertError(err)
}
示例3: openPorts
func openPorts() {
context, err = zmq.NewContext()
utils.AssertError(err)
optionsPort, err = utils.CreateInputPort(context, *optionsEndpoint)
utils.AssertError(err)
inPort, err = utils.CreateInputPort(context, *inputEndpoint)
utils.AssertError(err)
}
示例4: openPorts
// openPorts create ZMQ sockets and start socket monitoring loops
func openPorts() {
optionsPort, err = utils.CreateInputPort("influxdb/write.options", *optionsEndpoint, nil)
utils.AssertError(err)
inPort, err = utils.CreateInputPort("influxdb/write.in", *inputEndpoint, inCh)
utils.AssertError(err)
if *errorEndpoint != "" {
errPort, err = utils.CreateOutputPort("influxdb/write.err", *errorEndpoint, errCh)
utils.AssertError(err)
}
}
示例5: openPorts
func openPorts() {
optsPort, err = utils.CreateInputPort("mqtt-property.options", *optionsEndpoint, nil)
utils.AssertError(err)
tmplPort, err = utils.CreateInputPort("mqtt-property.template", *templateEndpoint, nil)
utils.AssertError(err)
propPort, err = utils.CreateOutputPort("mqtt-property.property", *propertyEndpoint, outCh)
utils.AssertError(err)
if *errorEndpoint != "" {
errPort, err = utils.CreateOutputPort("mqtt-property.err", *errorEndpoint, nil)
utils.AssertError(err)
}
}
示例6: openPorts
// openPorts create ZMQ sockets and start socket monitoring loops
func openPorts() {
inPort, err = utils.CreateInputPort("debug/crasher.in", *inputEndpoint, inCh)
utils.AssertError(err)
outPort, err = utils.CreateOutputPort("debug/crasher.out", *outputEndpoint, outCh)
utils.AssertError(err)
}
示例7: openPorts
// openPorts create ZMQ sockets and start socket monitoring loops
func openPorts() {
inPort, err = utils.CreateInputPort("", *inputEndpoint, nil)
utils.AssertError(err)
outPort, err = utils.CreateOutputPort("bonjour/discover.out", *outputEndpoint, outCh)
utils.AssertError(err)
}
示例8: openPorts
// openPorts create ZMQ sockets and start socket monitoring loops
func openPorts() {
inPort, err = utils.CreateInputPort("fs/watchdog.in", *inputEndpoint, nil)
utils.AssertError(err)
if *errorEndpoint != "" {
errPort, err = utils.CreateOutputPort("fs/watchdog.err", *errorEndpoint, errCh)
utils.AssertError(err)
}
}
示例9: mainLoop
// mainLoop initiates all ports and handles the traffic
func mainLoop() {
openPorts()
defer closePorts()
// Receiver routine
go func() {
inPort, err = utils.CreateInputPort("websocket/server.in", *inputEndpoint, inCh)
utils.AssertError(err)
defer inPort.Close()
for {
ip, err := inPort.RecvMessageBytes(0)
if err != nil {
continue
}
if !runtime.IsValidIP(ip) {
continue
}
msg, err := wsutils.IP2Message(ip)
if err != nil {
log.Println("Failed to convert IP to Message:", err.Error())
continue
}
log.Printf("Received response: %#v\n", msg)
DefaultHub.Outgoing <- *msg
}
}()
// Sender routine
go func() {
outPort, err = utils.CreateOutputPort("websocket/server.out", *outputEndpoint, outCh)
utils.AssertError(err)
defer outPort.Close()
for msg := range DefaultHub.Incoming {
log.Printf("Received data from connection: %#v\n", msg)
ip, err := wsutils.Message2IP(&msg)
if err != nil {
log.Println("Failed to convert Message to IP:", err.Error())
continue
}
outPort.SendMessageDontwait(ip)
}
}()
waitCh := make(chan bool)
go func() {
total := 0
for {
select {
case v := <-inCh:
if !v {
log.Println("IN port is closed. Interrupting execution")
exitCh <- syscall.SIGTERM
break
} else {
total++
}
case v := <-outCh:
if !v {
log.Println("OUT port is closed. Interrupting execution")
exitCh <- syscall.SIGTERM
break
} else {
total++
}
}
if total >= 2 && waitCh != nil {
waitCh <- true
}
}
}()
log.Println("Waiting for port connections to establish... ")
select {
case <-waitCh:
log.Println("Ports connected")
waitCh = nil
case <-time.Tick(30 * time.Second):
log.Println("Timeout: port connections were not established within provided interval")
exitCh <- syscall.SIGTERM
return
}
log.Println("Waiting for configuration...")
var bindAddr string
for {
ip, err := optionsPort.RecvMessageBytes(0)
if err != nil {
continue
}
if !runtime.IsValidIP(ip) || !runtime.IsPacket(ip) {
continue
}
bindAddr = string(ip[1])
break
}
optionsPort.Close()
// Configure & start websocket server
http.Handle("/", websocket.Handler(WebHandler))
//.........這裏部分代碼省略.........
示例10: openPorts
// openPorts create ZMQ sockets and start socket monitoring loops
func openPorts() {
optionsPort, err = utils.CreateInputPort("websocket/server.options", *optionsEndpoint, nil)
utils.AssertError(err)
}