A COBOL core in a modern project
This group is one small project, built and run in this container: a
COBOL program that prices orders, and a Python HTTP service that runs
it for a client. The COBOL does the arithmetic and the validation; the
modern layer owns the protocol, the JSON, the timeouts and the HTTP
status. Everything is shown as it was run.
The shape is deliberate and it is the one most modernisation projects
arrive at: the working COBOL stays where it is, the interface to it is
a fixed-width record, and a new program wraps it. The pages cover the
contract, the core, the service, its failures, its tests, a second way
to call the same core through ctypes, the
Dockerfile, and what a production version should change.
The files
Nine files, in the order a reader meets them. The two built files are not in the repository.
priceif.cpy — the request and answer records, the contract
price.cob — PRICE (stdin/stdout) and PRICECORE (the unit)
coretest.cob — the COBOL test driver, five cases
requests.fixed — five sample requests, thirty bytes each
server.py — the HTTP layer, standard library only
test_service.py — six unittest cases
call_core.py — one call through the shared module
bench.py — subprocess against ctypes, measured
Dockerfile — the image, built on the host
Where to start
Start with the contract: it is thirty odd bytes and every other page depends on it. The SELECT and FD and Python lessons are the course material behind the core and the ctypes page.