如果您要索引一堆数据,则Flashlight应用程序将要求ES动态索引每个对象,而没有任何资源访问限制。您必须使用信号量来控制/限制对该共享资源的访问。
安装信号量库
npm i --save semaphore
编辑
PathMonitor.js文件,并将对ES资源的访问限制为1
PathMonitor.prototype = { _init: function () { this.sem = require('semaphore')(1); this.addMonitor = this.ref.on('child_added', this._process.bind(this, this._childAdded)); this.changeMonitor = this.ref.on('child_changed', this._process.bind(this, this._childChanged)); this.removeMonitor = this.ref.on('child_removed', this._process.bind(this, this._childRemoved)); }, ... _index: function (key, data, callback) { var that = this; that.sem.take(function () { that.esc.index({ index: that.index, type : that.type, id : key, body : data }, function (error, response) { that.sem.leave(); if (callback) { callback(error, response); } }.bind(that)); }); }, ...}对于付费计划,可能不需要这样做。



