gozdcf

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 4, 2013 License: MIT Imports: 7 Imported by: 0

README

gozdcf

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).

Documentation

See godoc or http://godoc.org/github.com/jtacoma/gozdcf

Known Issues

  • there is no support for setting options on a context.
  • when combining configuration sources, any socket options in later sources will replace all options in previous sources.
  • multi-valued settings (bind, connect, subscribe) in JSON will only accept arrays.
  • configuration validation is mostly absent.

License

Released under a BSD-style license that can be found in the LICENSE file.

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 ListenAndServe(appName string, sources ...interface{}) error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL