>_EXECUTIVE SUMMARY
stryke-zmq is an opt-in connector package in the stryke ecosystem. ZeroMQ client for stryke — the brokerless messaging library covering request/reply, publish/subscribe, push/pull pipeline, and dealer/router patterns.
libzmq is the C library every ZeroMQ binding wraps. It (plus libsodium) is vendored into the cdylib from source via zeromq-src and statically linked, so the published artifact has no system shared-library dependency.
~ARCHITECTURE
In-process cdylib design: the stryke side is a thin .stk library; the heavy code is a Rust cdylib dlopened on first use Zmq. stryke core never links against libzmq.
| Layer | Implementation |
|---|---|
| stryke library | lib/Zmq.stk — thin wrapper; serializes args to JSON, decodes responses, maps {error} to die and {timeout} to undef |
| cdylib | libstryke_zmq.{dylib,so} — 60 #[no_mangle] zmq__* exports, JSON-string-in / JSON-string-out, catch_unwind at the boundary |
| State | One shared zmq::Context + a socket registry Mutex<HashMap<u64, Socket>> in OnceCell; sockets persist across calls |
| Thread safety | zmq::Socket is Send, not Sync; the mutex gives one-thread-at-a-time access + the cross-thread memory fence libzmq requires |
| Native dependency | libzmq + libsodium vendored from source via zeromq-src (cmake), statically linked — no system libzmq |
| Build | Cargo cdylib crate (publish = false); ships via s pkg install -g . or a prebuilt release tarball per host triple |
| Tests | 55 Rust unit + FFI-contract tests over inproc:// + 219 stryke assertions (162 functional + 57 surface-completeness) + 21 docs/readme/man/workflow lint gates |
| Public surface | 62 Zmq::* functions in lib/Zmq.stk — socket ops over the cdylib + pure helpers (validation, endpoint, topic, table) with no FFI socket call |
| CI | .github/workflows/ci.yml — fmt + clippy -D warnings + test on Linux/macOS, doc, release-build matrix, docs gates |
$SOCKET PATTERNS
| Pattern | Socket types | Use |
|---|---|---|
| Request / Reply | req, rep | synchronous RPC-style exchange |
| Publish / Subscribe | pub, sub, xpub, xsub | topic-filtered fan-out |
| Push / Pull | push, pull | load-balanced pipeline / fan-out work |
| Dealer / Router | dealer, router | async, identity-addressed routing |
| Exclusive pair | pair | 1:1 inproc thread coordination |
| Raw stream | stream | non-ZMTP TCP peers |
Transports: tcp://, ipc://, inproc://, and multicast pgm:// / epgm://.
@FUNCTION FAMILIES
The 62 Zmq::* functions split into socket ops (require a live handle, cross the FFI boundary to libzmq) and pure helpers (validation/endpoint/topic/table utilities that create no socket).
| Family | Functions |
|---|---|
| Introspection | version lib_version has capabilities io_threads |
| Lifecycle | socket socket_pair socket_count close bind connect unbind disconnect |
| Send / receive | send send_multipart recv recv_multipart recv_more drain sendrecv request |
| Pub/sub | subscribe unsubscribe |
| Options / readiness | set get poll poll_many events |
| Monitor / proxy | monitor monitor_recv proxy |
| CURVE / Z85 | curve_keypair curve_public valid_curve_key z85_encode z85_decode z85_valid |
| Endpoint helpers (pure) | parse_endpoint build_endpoint endpoint_bind_to_connect endpoint_connect_to_bind valid_endpoint |
| Topic / subscription (pure) | topic_match topic_match_any topic_overlaps prune_subscriptions subscription_diff build_subscription parse_subscription |
| Type / table (pure) | valid_socket_type socket_types socket_type_id socket_peers socket_types_compatible socket_caps socket_caps_all socket_option_names valid_socket_option encoding_names socket_event_names monitor_event_flag parse_monitor_event |
&WHY OPT-IN (NOT BUILTIN)
libzmq is the canonical native ZeroMQ library. Bundled here as an opt-in stryke package so workflows that need it don't bloat the core binary. The trade-off is intentional — the core stryke binary stays slim precisely because each connector ships separately. Daily-driver work (one-liners, awk replacement, data scripting) doesn't need ZeroMQ, Kafka, or database drivers linked in.
/FFI PROTOCOL
JSON over the FFI boundary. Each export takes a JSON-encoded args dict (a C string) and returns a JSON object (a C string the caller frees with stryke_free_cstring). Sockets are referenced by an integer handle returned from zmq__socket.
# create a socket -> handle
{"type":"rep","bind":"tcp://*:5555"} -> {"handle":1,"type":"rep"}
# send / recv
{"handle":1,"data":"pong"} -> {"ok":true,"bytes":4}
{"handle":2,"timeout_ms":1000} -> {"data":"pong","bytes":4}
# timeout (not an error) and error shapes
{"timeout":true}
{"error":"unknown socket handle: 99"}
%SCOPE
See the README's "Why this is a package" and API reference for the authoritative scope. v0.17.0 covers socket lifecycle (create/close/bind/connect/unbind/disconnect, socket_pair, socket_count), send/recv (single, multipart, recv_more, non-blocking drain, sendrecv), pub/sub topic filters, the full socket-option table (set/get), poll/poll_many/events readiness, socket-event monitoring (monitor/monitor_recv), a backgrounded proxy device, binary-safe hex/base64 payloads, the Z85 codec + CURVE key generation (curve_keypair, curve_public, valid_curve_key; CURVE auth via curve_* options), context io_threads tuning, a one-shot REQ convenience (request), and pure topology/endpoint/table helpers (endpoint_bind_to_connect, endpoint_connect_to_bind, valid_endpoint, build_subscription, parse_subscription, topic_overlaps, prune_subscriptions, subscription_diff, socket_caps_all, parse_monitor_event). Open roadmap: a streaming recv callback loop for long-running SUB/PULL consumers and a higher-level steerable-proxy control helper (PAUSE/RESUME/TERMINATE).
#PROJECT METADATA
| Item | Value |
|---|---|
| License | MIT |
| Author | MenkeTechnologies |
| Repository | github.com/MenkeTechnologies/stryke-zmq |
| Parent language | strykelang |
| Meta umbrella | MenkeTechnologiesMeta |
| Issues | github.com/MenkeTechnologies/stryke-zmq/issues |