/** * @protected * @param {object} options */ initialize(options) { super.initialize(options); if (!fs.existsSync(options.dataDirectory)) { mkdirpSync(options.dataDirectory); } this.fileMode = 'a+'; this.writeBuffer = Buffer.allocUnsafe(options.writeBufferSize >>> 0); // jshint ignore:line this.writeBufferCursor = 0; this.flushCallbacks = []; this.flushDelay = options.flushDelay >>> 0; // jshint ignore:line this.syncOnFlush = !!options.syncOnFlush; }
/** * @private * @param {Storage} storage The storage to create the consumer for. * @param {string} indexName The name of the index to consume. * @param {string} identifier The unique name to identify this consumer. */ initializeStorage(storage, indexName, identifier) { this.storage = storage; this.index = this.storage.openIndex(indexName); this.indexName = indexName; const consumerDirectory = path.join(this.storage.indexDirectory, 'consumers'); this.fileName = path.join(consumerDirectory, this.storage.storageFile + '.' + indexName + '.' + identifier); if (!fs.existsSync(consumerDirectory)) { mkdirpSync(consumerDirectory); } else { this.cleanUpFailedWrites(consumerDirectory); } }
if (!fs.existsSync(config.dataDirectory)) { try { mkdirpSync(config.dataDirectory); } catch (e) {
super(name, config); if (!fs.existsSync(this.dataDirectory)) { mkdirpSync(this.dataDirectory);