Tag: 节点光纤

从服务器上的Meteor集合中获取项目将引发“无法等待没有光纤”

我正在做一个相当简单的meteor应用程序,第一次应该查询所有从某个回购协议的git问题。 从github api获取问题清单之后,其想法是从这些问题中创build一个任务集合。 但是,每当我尝试查询当前任务的列表,我得到: …/.meteor/tools/c2a0453c51/lib/node_modules/fibers/future.js:83 W20140418-17:00:43.872(-7)? (STDERR) throw new Error('Can\'t wait without a fiber'); W20140418-17:00:43.872(-7)? (STDERR) ^ W20140418-17:00:43.889(-7)? (STDERR) Error: Can't wait without a fiber W20140418-17:00:43.889(-7)? (STDERR) at Function.wait (…/.meteor/tools/c2a0453c51/lib/node_modules/fibers/future.js:83:9) W20140418-17:00:43.890(-7)? (STDERR) at Object.Future.wait (…/.meteor/tools/c2a0453c51/lib/node_modules/fibers/future.js:325:10) W20140418-17:00:43.890(-7)? (STDERR) at _.extend._nextObject (packages/mongo- livedata/mongo_driver.js:805) W20140418-17:00:43.890(-7)? (STDERR) at _.extend.forEach (packages/mongo-livedata/mongo_driver.js:836) W20140418-17:00:43.890(-7)? (STDERR) at Cursor.(anonymous function) [as forEach] (packages/mongo- livedata/mongo_driver.js:695) […]

node.js光纤与pg / postgres

我一直在试图弄清楚如何使用节点光纤来使我的数据库代码在node.js中不那么混乱,但我无法让它工作。 作为一个最小的testing用例,我将代码解释为: var Future = require('fibers/future'); var pg=require('pg'); var connstr = "pg://not_the_real_user:or_password@localhost/db"; var pconnect = Future.wrap(pg.connect); Fiber(function() { var client = pconnect(connstr).wait(); console.log("called function"); }).run(); 如果我离开它,我得到以下错误: pgfuture.js:10 }).run(); ^ TypeError: undefined is not a function at Object.PG.connect.pools.(anonymous function).genericPool.Pool.create (/home/erik/code/treehouse-node/node_modules/pg/lib/index.js:49:20) at dispense (/home/erik/code/treehouse-node/node_modules/pg/node_modules/generic-pool/lib/generic-pool.js:223:17) at Object.exports.Pool.me.acquire (/home/erik/code/treehouse-node/node_modules/pg/node_modules/generic-pool/lib/generic-pool.js:267:5) at PG.connect (/home/erik/code/treehouse-node/node_modules/pg/lib/index.js:75:15) at Future.wrap (/home/erik/code/treehouse-node/node_modules/fibers/future.js:30:6) at /home/erik/code/treehouse-node/pgfuture.js:8:18 但是,如果我注释掉调用pconnect的那一行,我会在控制台上看到“调用函数”消息,并且没有错误。 在github页面上的例子有一个几乎相同的结构,它在我的系统上正常工作,但我很难在这里做错了什么。 […]

meteor和光纤/ bindEnvironment()发生了什么?

我有困难使用Fibers / Meteor.bindEnvironment()。 如果集合开始为空,我试图进行代码更新并插入到集合中。 这一切都应该在启动时运行在服务器端。 function insertRecords() { console.log("inserting…"); var client = Knox.createClient({ key: apikey, secret: secret, bucket: 'profile-testing' }); console.log("created client"); client.list({ prefix: 'projects' }, function(err, data) { if (err) { console.log("Error in insertRecords"); } for (var i = 0; i < data.Contents.length; i++) { console.log(data.Contents[i].Key); if (data.Contents[i].Key.split('/').pop() == "") { Projects.insert({ name: data.Contents[i].Key, […]

为什么meteor.js是同步的?

不是代码效率是同步的吗? 为什么编码同步取胜? 我发现这两个链接在做一些研究: http : //bjouhier.wordpress.com/2012/03/11/fibers-and-threads-in-node-js-what-for/,https : //github.com /贤者/ streamlinejs / 如果目标是防止意大利面代码,那么显然你可以有asynchronous代码,例如streamline.js,这不是一个callback金字塔,对吧?