栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何确保在ElasticSearch Bonsai Free实例中使用Firebase FlashLight为每个对象建立索引

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何确保在ElasticSearch Bonsai Free实例中使用Firebase FlashLight为每个对象建立索引

如果您要索引一堆数据,则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));        });    },    ...}

对于付费计划,可能不需要这样做。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/397834.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号