/qzmq

qzmq provides Q bindings for CZMQ, the high-level C binding for ØMQ.

Primary LanguageCGNU Affero General Public License v3.0AGPL-3.0

Title: README Date: 20130223

# qzmq

qzmq provides Q bindings for CZMQ, the high-level C binding for ØMQ.

This is version 1.2.0-RC4 of qzmq.

  • 1.2.0-RC4: benchmark optimization
  • 1.2.0-RC3: benchmarks added in perf/; new assert.q utilities
  • 1.2.0-RC2: installation instructions for RHEL6/CentOS6, Ubuntu, Mac OS X
  • 1.2.0-RC1: documentation added
  • 1.2.0-RC0: CZMQ 1.2.0 support

qzmq is written and maintained by Jaeheum Han.

qzmq is hosted at github and it uses the issue tracker for all issues and comments.

## Contents

Features of qzmqLicenseFiles of qzmqBuilding qzmqA Quick Tour of qzmqA Longer Tour of qzmqIssues

## Features of qzmq qzmq lets Q users write
  • concurrent code using multi-threads,
  • distributed systems connecting with systems
    • written in other languages,
    • written with many software patterns,
  • developed by the ØMQ community.
## License

Dual licenses:

  • the GNU Affero General Public License version 3
  • More permissible licenses (TBD)

Copyright (c) 2012, 2013 Jaeheum Han

This file is part of qzmq.

qzmq is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

## Files of qzmq
  • COPYING -- GNU Affero General Public License.
  • README.md -- README.txt in Markdown syntax thanks to Gitdown.
  • README.txt -- this file.
  • demos/* -- demos. See demos/README.txt or demos/README.md.
  • doc.q -- a script to generate doc.txt.
  • doc.txt -- qzmq API doc or .qzmq.doc (see below) in text format generated by doc.q.
  • how-to-install-zeromq-czmq.md -- installation instructions for ZeroMQ and CZMQ (how-to-install-zeromq-czmq.txt)
  • kx/* -- k.h and c.o from kx.com for building qzmq. (see http://code.kx.com/wiki/TermsAndConditions)
  • qzmq.c -- C bindings to be linked with CZMQ (with ØMQ) and Q (k.h and c.o).
  • qzmq.q -- q code used to load the bindings.
  • qzmq.so -- dynamic library to be loaded into q by qzmq.q.
  • qzmq_test.q -- test code translated to q from CZMQ's self-test code.
## Building qzmq Prerequisites: kdb+ 2.8 or 3.0 (32-bit) for Linux and Mac, [ØMQ][zeromq] 2.2, [CZMQ][czmq] 1.2.0. Follow `how-to-install-zeromq-czmq.md` or `how-to-install-zeromq-czmq.txt` to install ZeroMQ and CZMQ.

Current version 1.2.0-RC4 of qzmq has been built with 32-bit kdb+ on Ubuntu 12.10. Instructions for builidng qzmq assumes kdb+ is instaled under $HOME/q/ directory.

# for Mac OS X (kdb+ v2.8 "m32")
gcc -m32 -bundle -undefined dynamic_lookup qzmq.c -o $HOME/q/m32/qzmq.so \
    -Wall -Wextra \
    -I./kx/kdb+2.8  -I/usr/local/include/ \
    -L./kx/kdb+2.8/m32 -L/usr/local/lib -lzmq -lczmq
cp qzmq.q assert.q $HOME/q/

# for RHEL6, CentOS 6, etc. (kdb+ v2.8 "l32") with prebuilt ZeroMQ & CZMQ in /usr/lib
gcc -m32 -shared -fPIC qzmq.c -o $HOME/q/l32/qzmq.so \
    -Wall -Wextra  -Wl,-rpath -Wl,/usr/lib \
    -I./kx/kdb+2.8  -I/usr/include/ \
    -L./kx/kdb+2.8/l32 -L/usr/lib -lzmq -lczmq
cp qzmq.q assert.q $HOME/q/

# for Debian, Ubuntu, ... (kdb+ v2.8 "l32") with ZeroMQ & CZMQ in /usr/local/lib, built from the source.
gcc -m32 -shared -fPIC qzmq.c -o $HOME/q/l32/qzmq.so \
    -Wall -Wextra  -Wl,-rpath -Wl,/usr/local/lib \
    -I./kx/kdb+2.8  -I/usr/local/include/ \
    -L./kx/kdb+2.8/l32 -L/usr/local/lib -lzmq -lczmq
cp qzmq.q assert.q $HOME/q/

# for Mac OS X (kdb+ v3.0 "m32")
gcc -DKXVER=3  -m32 -bundle -undefined dynamic_lookup qzmq.c -o $HOME/q/m32/qzmq.so \
    -Wall -Wextra \
    -I./kx/kdb+3.0  -I/usr/local/include/ \
    -L./kx/kdb+3.0/m32 -L/usr/local/lib -lzmq -lczmq
cp qzmq.q assert.q $HOME/q/

# for RHEL6, CentOS 6, etc. (kdb+ v3.0 "l32") with prebuilt ZeroMQ & CZMQ in /usr/lib
gcc -DKXVER=3 -m32 -shared -fPIC qzmq.c -o $HOME/q/l32/qzmq.so \
    -Wall -Wextra  -Wl,-rpath -Wl,/usr/lib \
    -I./kx/kdb+3.0  -I/usr/include/ \
    -L./kx/kdb+3.0/l32 -L/usr/lib -lzmq -lczmq
cp qzmq.q assert.q $HOME/q/

# for Debian, Ubuntu, ... (kdb+ v3.0 "l32") with ZeroMQ & CZMQ in /usr/local/lib, built from the source.
gcc -DKXVER=3 -m32 -shared -fPIC qzmq.c -o $HOME/q/l32/qzmq.so \
    -Wall -Wextra  -Wl,-rpath -Wl,/usr/local/lib \
    -I./kx/kdb+3.0 -I/usr/local/include/ \
    -L./kx/kdb+3.0/l32 -L/usr/local/lib -lzmq -lczmq
cp qzmq.q assert.q $HOME/q/
## A Quick Tour of qzmq

Load qzmq; learn to read online documentation; write multi-threading code in q; ...

q)\l qzmq.q  / loads various czmq APIs named z* and libzmq; also creates .qzmq.doc.
q)\v
`libzmq`zclock`zctx`zfile`zframe`zloop`zmq`zmsg`zsocket`zsockopt`zstr`zthread
q)type libzmq  / is for a few helper functions in the low level zeromq API.
99h
q)libzmq  / has two functions, version and device.
version| code
device | code
q)type .qzmq.doc / is a 99h that can be queried
99h
q)meta .qzmq.doc
c   | t f a
----| -----
name| s    
args| s    
doc | s    
q).qzmq.doc / same as doc.txt (generated by doc.q)
name              | args  doc                                                ..
------------------| ---------------------------------------------------------..
qzmq              |       see https://github.com/jaeheum/qzmq/blob/master/REA..
czmq              |       see http://czmq.zeromq.org or 'man czmq'.          ..
zmq               |       see zmq, czmq z* api man pages, `zsockopt and `zsoc..
zsockopt          |       see http://czmq.zeromq.org/manual:zsockopt or 'man ..
zhash             |       nyi.                                               ..
zlist             |       nyi.                                               ..
zclock            |       see http://czmq.zeromq.org/manual:zclock or 'man zc..
zclock.sleep      | [x]   sleeps for x milliseconds (-6h).                   ..
zclock.time       | []    returns the current timestamp in milliseconds (-7h)..
zclock.log        | [x]   prints YY-mm-dd, followed by x (10h).              ..
....
q).qzmq.doc`libzmq  / shows the documentation hyperlink.
args| 
doc | see http://api.zeromq.org or 'man zmq'.
q).qzmq.doc`libzmq.version  / shows documentation of a particular function.
args| []
doc | returns major, minor, patch version numbers (6h) of libzmq.
q)libzmq.version[]  / returns major, minor, patch version numbers (6h) of libzmq.
2 2 0
q).qzmq.doc`zclock
args| 
doc | see http://czmq.zeromq.org/manual:zclock or 'man zclock'.
q).qzmq.doc`zclock.sleep
args| [x]
doc | sleeps for x milliseconds (-6h).
q)select from .qzmq.doc where name like "zthread*"
name        | args    doc                                                    ..
------------| ---------------------------------------------------------------..
zthread     |         see http://czmq.zeromq.org/manual:zthread or 'man zthre..
zthread.new | [x;y]   creates a detached thread running `x[y].               ..
zthread.fork| [x;y;z] creates an attached thread running `y[z] in the zctx x...
q) / launch some detached threads
q)dthr:{zclock.log x; zclock.sleep 1000i*1000i; :0N}
q)i:0; do[10; zthread.new[`dthr; "tid",string i]; i+:1]
12-10-05 23:31:22 tid1
12-10-05 23:31:22 tid0
12-10-05 23:31:22 tid2
12-10-05 23:31:22 tid3
12-10-05 23:31:22 tid4
12-10-05 23:31:22 tid5
12-10-05 23:31:22 tid6
12-10-05 23:31:22 tid7
12-10-05 23:31:22 tid8
q)12-10-05 23:31:22 tid9
q) / check there are ten threads under q on a linux machine
q)\pstree
"init-+-atd"
"     |-auditd---{auditd}"
"     |-crond"
"     |-dbus-daemon"
"     |-2*[dhclient]"
"     |-6*[mingetty]"
"     |-ntpd"
"     |-rsyslogd---2*[{rsyslogd}]"
"     |-sshd---sshd---sshd---bash---q-+-sh---pstree"
"     |                               `-10*[{q}]"
"     `-udevd"
q) / check there are ten threads under q on a mac os x
q)\ps -o ppid -M
" PPID USER   PID   TT   %CPU STAT PRI     STIME     UTIME COMMAND"
"  349 hjh    171 s000    0.0 S    31T   0:00.03   0:00.02 rlwrap /Users/hjh/..
"  347 hjh    349 s000    0.0 S    31T   0:03.05   0:04.63 -bash"
"21825 hjh  21826 s001    0.0 S    31T   0:00.40   0:00.54 -bash"
"56075 hjh  21989 s002    0.0 S    31T   0:00.05   0:00.89 swipl"
"56074 hjh  56075 s002    0.0 S    31T   0:02.43   0:03.69 -bash"
" 4928 hjh    611 s003    0.0 S    31T   0:00.01   0:00.01 rlwrap /Users/hjh/..
" 4927 hjh   4928 s003    0.0 S    31T   0:00.99   0:01.73 -bash"
"  611 hjh    612 s004    0.0 S    31T   0:00.01   0:00.02 /Users/hjh/q/m32/q"
"  611        612         0.0 S    31T   0:00.00   0:00.00 "
"  611        612         0.0 S    31T   0:00.00   0:00.00 "
"  611        612         0.0 S    31T   0:00.00   0:00.00 "
"  611        612         0.0 S    31T   0:00.00   0:00.00 "
"  611        612         0.0 S    31T   0:00.00   0:00.00 "
"  611        612         0.0 S    31T   0:00.00   0:00.00 "
"  611        612         0.0 S    31T   0:00.00   0:00.00 "
"  611        612         0.0 S    31T   0:00.00   0:00.00 "
"  611        612         0.0 S    31T   0:00.00   0:00.00 "
"  611        612         0.0 S    31T   0:00.00   0:00.00 "
"  612 hjh    622 s004    0.0 S    31T   0:00.00   0:00.00 sh -c ps -o ppid -..
"  171 hjh    172 s005    0.0 S    31T   0:00.06   0:00.04 /Users/hjh/q/m32/q"
"  171        172         0.0 S    31T   0:00.00   0:00.00 "
..
## A Longer Tour of qzmq

qzmq_test.q contains qzmq translation of czmq's self-tests. It can be used as examples of each API.

Code in demos/* shows cross-language clients and servers that are interchangeable.

ZeroMQ Guide has examples in many languages. Translation of these examples to q is under way (pulled from here). See Issue #5.

## Issues See the [issue tracker][issues].

README.txt is written in Gitdown.