Skip to content

Instantly share code, notes, and snippets.

@jtacoma
Last active December 12, 2015 04:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtacoma/4712643 to your computer and use it in GitHub Desktop.
Save jtacoma/4712643 to your computer and use it in GitHub Desktop.
A sample gozdcf-based application.
// 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)
}
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