function KCLProcess()

in lib/kcl/kcl_process.js [65:104]


function KCLProcess(recordProcessor, inputFile, outputFile, errorFile) {
  var allMethodsPresent = typeof recordProcessor.initialize === 'function' &&
    typeof recordProcessor.processRecords === 'function';
  allMethodsPresent = allMethodsPresent && ((typeof recordProcessor.leaseLost === 'function' &&
    typeof recordProcessor.shardEnded === 'function') || (typeof recordProcessor.shutdown === 'function'));
  if (!allMethodsPresent) {
    throw new Error('Record processor must implement initialize, processRecords, and shutdown functions.');
  }
  inputFile = typeof inputFile !== 'undefined' ? inputFile : process.stdin;
  outputFile = typeof outputFile !== 'undefined' ? outputFile : process.stdout;
  errorFile = typeof errorFile !== 'undefined' ? errorFile : process.stderr;

  var version = KCLManager.VERSION2;
  if (typeof recordProcessor.shutdown === 'function') {
    version = KCLManager.VERSION1;
  }

  var kclManagerInput = {
    recordProcessor: recordProcessor,
    version: version
  };

  var kclManager = new KCLManager(kclManagerInput, inputFile, outputFile, errorFile, version);

  return {
    // For testing only.
    _kclManager: kclManager,

    /**
     * Starts this KCL process's main loop.
     */
    run: function () {
      kclManager.run();
    },

    cleanup: function() {
      kclManager._cleanup();
    }
  };
}