Module pacchettino

A job queue made of plain directories: one program sends jobs, another one (or many, in other processes or threads) processes them.

A job is either some bytes (sendData) or a file (sendFile). It is in the filesystem before send* returns, so nothing is lost if a program stops or crashes (set Pacchettino.durable to survive power cuts too), and a job left half done by a process that died is detected and moved to interrupted/. Each job is given to one consumer only, even with many consumers on the same directory. No server, no database, no dependencies.

Example

// Producer
auto queue = new Pacchettino("/var/spool/myapp");
queue.sendFile("video.mp4");
queue.sendData("resize photo 42", 10.minutes);   // not before 10 minutes

// Consumer, in another program
auto queue = new Pacchettino("/var/spool/myapp");
queue.onFileReceived = (id, name, path) {
    upload(path);
    return Pacchettino.Result.SUCCESS;   // or FAILED, or RETRY
};

while (true) queue.receiveOne(5.seconds);

Where to start:

Works on Linux, macOS, BSD and Windows.

See Also

the README for a guided tour, llms-full.txt for the whole API in one file.

Classes

NameDescription
Pacchettino A simple file-based queue system designed to be safe for concurrent use across multiple threads and processes.