Skip to content

jkristia/node-py-zeromq

Repository files navigation

TsPyZeroMq

TypeScript Express gateway (“MyApp”) that forwards HTTP calls to a Python asyncio ROUTER service (“NumberService”) over ZeroMQ. Used to explore DEALER/ROUTER patterns, concurrent request handling, and cross-language messaging.

Components

  • myapp/ – Node.js 20+ service written in TypeScript. Exposes /health and /api/number-service/test, then relays test messages to NumberService via ZeroMQ DEALER.
  • numberService/ – Python 3.12 async worker built with pyzmq. Listens on a ROUTER socket and returns timestamped responses.
  • docker-compose.yml – Boots NumberService plus two MyApp instances (session-1 on port 8001 and session-2 on port 8002) to demonstrate concurrent clients.
  • concurrency_test.py – Async httpx script that verifies both sessions’ /health endpoints and hammers /api/number-service/test five times in parallel.

Prerequisites

  • Node.js 20+
  • Python 3.12+
  • Docker + Docker Compose (for the container workflow)

Quick Start

make install             # sets up Python venv + npm packages
make compose-build-run   # rebuilds images and launches all services
python concurrency_test.py

Use make compose-down when you are done.

Development Tips

  • Run MyApp locally with CLI flags instead of env vars:
    cd myapp
    npm run dev -- --session-id=session-1 --http-port=8001 --router-endpoint=tcp://127.0.0.1:5555
  • Start NumberService directly in another shell:
    python numberService/src/main.py --router-endpoint=tcp://127.0.0.1:5555
  • Smoke-test the whole path at any time via python concurrency_test.py; it will fail fast if either service is unreachable or the ZeroMQ hop is unhealthy.

The HTTP surface intentionally stays small (health check + test endpoint) so you can focus on ZeroMQ behavior, CLI-driven configs, and multi-instance orchestration.

About

project created entirely by prompting github copilot. (GPT-5.1-Codex model)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors