Documentation ¶
Overview ¶
This package provides methods for consuming ZeroMQ Device Configuration Files (ZDCF, http://rfc.zeromq.org/spec:17) for ØMQ (ZeroMQ, ZMQ, http://www.zeromq.org/) applications that use gozmq (http://godoc.org/github.com/alecthomas/gozmq).
Example ¶
defaults := ` version = 0.1 echo1 type = echo_once cliff type = REP bind = tcp://127.0.0.1:5557 yodel42 type = yodel_once vocals type = REQ connect = tcp://127.0.0.1:5557 ` RegisterFunc("echo_once", func(ctx *DeviceContext) { cliff := ctx.MustOpen("cliff") defer cliff.Close() msg, err := cliff.Recv(0) if err != nil { panic(err) } cliff.Send(msg, 0) }) RegisterFunc("yodel_once", func(ctx *DeviceContext) { vocals := ctx.MustOpen("vocals") defer vocals.Close() vocals.Send([]byte("YOOOODEL!"), 0) msg, _ := vocals.Recv(0) fmt.Println(string(msg)) }) err := ListenAndServe("myapp", defaults) if err != nil { fmt.Println("error:", err.Error()) }
Output: YOOOODEL!
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ListenAndServe ¶
func RegisterFunc ¶
func RegisterFunc(deviceTypePattern string, device func(*DeviceContext)) error
Types ¶
type DeviceContext ¶
type DeviceContext struct {
// contains filtered or unexported fields
}
A DeviceContext is intended to be all that a ØMQ device needs to do its job.
func (*DeviceContext) MustOpen ¶
func (d *DeviceContext) MustOpen(name string) zmq.Socket
MustOpen creates and binds/connects the named socket or else panics.
func (*DeviceContext) Open ¶
func (d *DeviceContext) Open(name string) (sock zmq.Socket, err error)
Open creates and binds/connects the named socket.
func (*DeviceContext) Type ¶
func (d *DeviceContext) Type() string
Type is the name of the device type intended to be instantiated.
This is a string that should be translated to a func (or switch'd to a code block) that knows how to create that type of device.
Click to show internal directories.
Click to hide internal directories.