Last active
December 12, 2015 04:09
-
-
Save jtacoma/4712643 to your computer and use it in GitHub Desktop.
A sample gozdcf-based application.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Though it's not necessary, you might want to run this with environment | |
// variable GOMAXPROCS set to the number of CPUs on your machine. | |
// | |
// For example, at a bash prompt: | |
// | |
// $ GOMAXPROCS=4 go run echo.go | |
// | |
package main | |
import ( | |
"io/ioutil" | |
zdcf "github.com/jtacoma/gozdcf" | |
) | |
func Echo(ctx *zdcf.DeviceContext) { | |
surface := ctx.MustOpen("frontend") | |
defer surface.Close() | |
for { | |
msg, err := surface.Recv(0) | |
if err != nil { | |
panic(err) | |
} | |
surface.Send(msg, 0) | |
} | |
} | |
func main() { | |
zdcf.DeviceFunc("echo", Echo) | |
config, err := ioutil.ReadFile("zdcf.conf") | |
if err != nil { | |
panic(err) | |
} | |
zdcf.ListenAndServe("main", config) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
proxy | |
type = zmq_queue | |
frontend | |
type = ROUTER | |
bind = tcp://*:5555 | |
backend | |
type = DEALER | |
bind = tcp://127.0.0.1:5556 | |
echo0 | |
type = echo | |
frontend | |
type = REP | |
connect = tcp://127.0.0.1:5556 | |
echo1 | |
type = echo | |
frontend | |
type = REP | |
connect = tcp://127.0.0.1:5556 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment