Single Integration Contract: Process Spawn → Write stdin → Read stdout
Binaries execute headlessly with standard OS pipes. Communications enforce single-line Newline Delimited JSON (NDJSON) framing with zero local HTTP servers required.
using System;
using System.Diagnostics;
using System.Text;
using System.Threading.Tasks;
public class JustifiedWorkerEngine {
private readonly string _binaryPath;
private readonly string _licenseKey;
public JustifiedWorkerEngine(string binaryPath, string licenseKey) {
_binaryPath = binaryPath;
_licenseKey = licenseKey;
}
public async Task<string> ExecuteTransformationAsync(string inputJsonPayload) {
string singleLinePayload = inputJsonPayload.Replace("\r", "").Replace("\n", "\\n");
var startInfo = new ProcessStartInfo {
FileName = _binaryPath,
Arguments = $"--pipe --license {_licenseKey}",
RedirectStandardInput = true,
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true,
StandardOutputEncoding = Encoding.UTF8
};
using var process = Process.Start(startInfo);
using (var writer = process.StandardInput) {
await writer.WriteLineAsync(singleLinePayload);
}
return await process.StandardOutput.ReadLineAsync();
}
}
const { spawn } = require('child_process');
const readline = require('readline');
function executeJustifiedEngine(binaryPath, licenseKey, inputJsonPayload) {
return new Promise((resolve, reject) => {
const engineProcess = spawn(binaryPath, ['--pipe', '--license', licenseKey], {
windowsHide: true,
stdio: ['pipe', 'pipe', 'ignore']
});
const rl = readline.createInterface({ input: engineProcess.stdout });
rl.on('line', (line) => {
resolve(JSON.parse(line));
engineProcess.kill();
});
engineProcess.stdin.write(JSON.stringify(inputJsonPayload) + '\n');
engineProcess.stdin.end();
});
}