// STRYKE-ZMQ — ENGINEERING REPORT

Opt-in stryke connector package · cdylib libstryke_zmq (libzmq vendored) · loaded on use Zmq · JSON-over-FFI protocol

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

Zmq
use namespace
opt-in
Tier 2
cdylib
in-process FFI
60
zmq__* FFI exports
62
Zmq:: functions
55
Rust tests

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

LayerImplementation
stryke librarylib/Zmq.stk — thin wrapper; serializes args to JSON, decodes responses, maps {error} to die and {timeout} to undef
cdyliblibstryke_zmq.{dylib,so} — 60 #[no_mangle] zmq__* exports, JSON-string-in / JSON-string-out, catch_unwind at the boundary
StateOne shared zmq::Context + a socket registry Mutex<HashMap<u64, Socket>> in OnceCell; sockets persist across calls
Thread safetyzmq::Socket is Send, not Sync; the mutex gives one-thread-at-a-time access + the cross-thread memory fence libzmq requires
Native dependencylibzmq + libsodium vendored from source via zeromq-src (cmake), statically linked — no system libzmq
BuildCargo cdylib crate (publish = false); ships via s pkg install -g . or a prebuilt release tarball per host triple
Tests55 Rust unit + FFI-contract tests over inproc:// + 219 stryke assertions (162 functional + 57 surface-completeness) + 21 docs/readme/man/workflow lint gates
Public surface62 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

PatternSocket typesUse
Request / Replyreq, repsynchronous RPC-style exchange
Publish / Subscribepub, sub, xpub, xsubtopic-filtered fan-out
Push / Pullpush, pullload-balanced pipeline / fan-out work
Dealer / Routerdealer, routerasync, identity-addressed routing
Exclusive pairpair1:1 inproc thread coordination
Raw streamstreamnon-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).

FamilyFunctions
Introspectionversion lib_version has capabilities io_threads
Lifecyclesocket socket_pair socket_count close bind connect unbind disconnect
Send / receivesend send_multipart recv recv_multipart recv_more drain sendrecv request
Pub/subsubscribe unsubscribe
Options / readinessset get poll poll_many events
Monitor / proxymonitor monitor_recv proxy
CURVE / Z85curve_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

ItemValue
LicenseMIT
AuthorMenkeTechnologies
Repositorygithub.com/MenkeTechnologies/stryke-zmq
Parent languagestrykelang
Meta umbrellaMenkeTechnologiesMeta
Issuesgithub.com/MenkeTechnologies/stryke-zmq/issues