{"_id":"kju","_rev":"26-3b83c87771afbf865921c8429c50fc54","name":"kju","description":"Fault tolerant queue that queues data for bulk updates","dist-tags":{"latest":"0.0.3"},"versions":{"0.0.1":{"name":"kju","version":"0.0.1","description":"Fault tolerant queue that queues data for bulk updates","homepage":"http://observer.no.de","keywords":["kju","queue","bulk","batch","updates"],"dependencies":{"eventemitter2":"0.4.1"},"devDependencies":{"should":"0.3.1","expresso":"0.8.1","long-stack-traces":"0.1.2"},"main":"index","_id":"kju@0.0.1","engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.0.12","_nodeVersion":"v0.4.8","_defaultsLoaded":true,"dist":{"shasum":"f65903adad7f5344ef464920aa34f2f3b34e44e1","tarball":"https://registry.npmjs.org/kju/-/kju-0.0.1.tgz","integrity":"sha512-BVTUqqVXY9BPgHI62mGqFBlWUrmhsvcbGcYPxToVEQK80R3Fk7PTjtfzB7/oQDICWOlCZOqWlzL5/Y/Xf+gVYA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAZu5zgo9XfTrS2kKNIWuh06OtyStyqf9dEFpl9RuIIOAiAzVDfOqjh87KnR2Mo3JQbBJxtUlllXiqHHLSLLyQLPVg=="}]},"scripts":{},"maintainers":[{"name":"V1","email":"info@3rd-Eden.com"}],"directories":{}},"0.0.2":{"name":"kju","version":"0.0.2","author":{"name":"Arnout Kazemier","email":"info@3rd-Eden.com"},"description":"Fault tolerant queue that queues data for bulk updates","homepage":"http://observer.no.de","keywords":["kju","queue","bulk","batch","updates"],"repository":{"type":"git","url":"git://github.com/observing/kju.git"},"dependencies":{"eventemitter2":"0.4.1"},"devDependencies":{"should":"0.3.1","expresso":"0.8.1","long-stack-traces":"0.1.2"},"main":"index","_npmJsonOpts":{"file":"/Users/arnout/.npm/kju/0.0.2/package/package.json","wscript":false,"contributors":false,"serverjs":false},"_id":"kju@0.0.2","engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.0.13","_nodeVersion":"v0.5.9","_defaultsLoaded":true,"dist":{"shasum":"7adf9c5804e2d7882798781f147eb6f1f61a1bd1","tarball":"https://registry.npmjs.org/kju/-/kju-0.0.2.tgz","integrity":"sha512-bwm1YLJ+fyqUs5gVvafWJOQz0bZx5EKp+vlGi44eOL/cQFQlyuaVI7APHFcRg/Amo/Og3iLi+iG7Wmf/BcSqaQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCkrqTBNuFVLXHOWevxkTr4CVOfB5UnONIUMo2AFDTs7QIgPa7pZMZHgLJhjRchPCfVDMGwS1ktBEooHd3FDSwzYi8="}]},"scripts":{},"maintainers":[{"name":"V1","email":"info@3rd-Eden.com"}],"directories":{}},"0.0.3":{"name":"kju","version":"0.0.3","author":{"name":"Arnout Kazemier","email":"info@3rd-Eden.com"},"description":"Fault tolerant queue that queues data for bulk updates","homepage":"http://observe.it","keywords":["kju","queue","bulk","batch","updates"],"repository":{"type":"git","url":"https://github.com/observing/kju.git"},"dependencies":{"eventemitter2":"0.4.11"},"devDependencies":{"chai":"1.4.x","mocha":"1.7.x","long-stack-traces":"0.1.2"},"main":"lib/kju.js","scripts":{"test":"make test"},"_id":"kju@0.0.3","dist":{"shasum":"66561385f07ac1e6d95560c4532859f7d4036c6e","tarball":"https://registry.npmjs.org/kju/-/kju-0.0.3.tgz","integrity":"sha512-ODyrb6s6IF3Qf2rJlZ8Tb9zfo/KhUAjsANolNQ11zvvAuB1qGkV44J4MVELG80X/Dh8b6yxk/i1YcsrNY+eQKA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDZjxaymz3nHwFd2pCmGfxm9DtvdNeyKG+JrNDe0VazFQIhAOqzr/Fud4hfBEv1dkhjDtLrPwijs4dwpEwL8UmrjkQL"}]},"_npmVersion":"1.1.68","_npmUser":{"name":"V1","email":"info@3rd-Eden.com"},"maintainers":[{"name":"V1","email":"info@3rd-Eden.com"}]}},"maintainers":[{"email":"info@martijnswaagman.nl","name":"swaagie"},{"email":"npm@3rd-Eden.com","name":"v1"},{"email":"npm@3rd-Eden.com","name":"3rdeden"}],"time":{"modified":"2022-06-19T08:55:24.802Z","created":"2011-09-16T21:00:56.667Z","0.0.1":"2011-09-16T21:00:57.306Z","0.0.2":"2011-09-16T22:52:00.960Z","0.0.3":"2013-01-02T09:29:27.632Z"},"repository":{"type":"git","url":"https://github.com/observing/kju.git"},"author":{"name":"Arnout Kazemier","email":"info@3rd-Eden.com"},"homepage":"http://observe.it","keywords":["kju","queue","bulk","batch","updates"],"readme":"# kju [![Build Status](https://secure.travis-ci.org/observing/kju.png)](http://travis-ci.org/observing/kju)\n\nkju (queue) is a evented and dynamic fault tolerant queueing system for\nNode.js. Node currently suffers from a big limitation, it does not support hot\ncode reload. So when you want to upgrade your site or service, you need to kill\nthe running process and have it restart again.\n\n### lol, wut?\n\nNode does not provide a way to do this safely, if you queued up data in memory\nit will be lost. If you where about to send a query to your database for a new\naccount.. You will be fucked. You can consider the query lost. Everything that\nwhere about to do is dropped.\n\n### how\n\nkju is designed to work around this limitation by doing a sync write of the\ndata to disk when the process.exit is about to occur. This needs to be done in\nsync mode as the next tick of the event loop in node might never fire. When kju\nstarts up again it will search for old data dumps and loads this back again in\nto the internal data structure where it's ready to be processed again. In\naddition to writing to disk, it will also send the complete JSON dump to the\n`stderr` so you have 2 snap shots to recover from.\n\n### use case\n\nA use case for kju would be buffering up data for batch inserts in to the\ndatabase. Some database are optimized for batch inserts so they don't have to\nreset the indexes on each insert, but they can just do it all in one shot.\n\n### evented dynamic or dynamically evented\n\nkju is designed to do inserts at a fixed interval that you have set. If kju is\nnot completely filled it will automatically decrease the interval so it has\nmore to fill up with data before it emits the `data` event. But if the buffer\nis filling up really quickly again it will increase the interval adjusting it\nself to your website's pressure and bursts.\n\nBut there are limits, it will only increase or decrease by a factor of 2 from\nthe set interval.\n\n## Installation\n\nThe easiest way to install kju is by using the Node Package Manager (NPM).\n\n```\nnpm install kju\n```\n\nIf npm is not available on your system you can fetch the latest version from\nthis Github repository.\n\n## API\n\n### configuring\n\nAdding kju to your application is quite simple\n\n```js\nvar kju = require('kju');\n```\n\nNow that you required the module you can create a new instance and configure\nit.\n\n```js\nvar q = new kju; // no configuration\n\nvar q = new kju({ limit: 100 }) // with configuration\n```\n\nThe following configuration flags are supported:\n\n- `limit` Limit of the buffer. Defaults to 500 items.\n- `ms` Amount of milliseconds to increase or decrease the interval. Defaults to 100 ms\n- `interval` Baseline interval for queue, this is where the minimum and maximum levels are based off.  Defaults to 15000 ms\n- `warnings` When enabled we will emit events when our maximum or minimum interval has been reached. Defaults to true.\n- `enabled` Enable the queue by default. Defaults to true.\n- `recover` Enable recovery of old `.kju` storage files so no data is lost when the process is exiting. Defaults to true.\n- `dump` In addition to the storage of `.kju` files also dump JSON to stderr. Defaults to false.\n- `path` Location where the `.kju` recover files are stored. Defaults to the current working directory.\n- `name` Name of the `.kju` recover files, should contain {sequence}.kju at the end for numbering. Defaults to node_kju_backup.{sequence}.kju.\n\n### events\n\n`error` (err) Error\n\nThe error event emitted in several crucial parts in the code. For example if\nyour supplied path does not exist, we cannot create a backup of your data. But\nthis event is also fired when the recovery of your backed up file has failed.\n\n`data` (data, length) Array, Number\n\nWhen kju has reached its limit it will fire off the the data event with queued\ndata that you can process. It also has a handy length parameter. Because\ncurrently there is no guarantee that the amount of data is the same as your set\nlimit. It might be more, it might be less.\n\n`maximum interval.warning` (null)\n\nWhen kju has reached it's maximum timeout and the warning option has been set\nto you can be notified by this event.\n\n`minimum interval.warning` (null)\n\nSame as above, but for the minimum timeout this one is probably the most\nusefull as it will give you a small indication of what load your queue is\ncurrently under and if you might need to adjust some settings.\n\n> Because we are using EventEmitter 2 you can actually listen to both warnings\nat once using `kju.on('\\*.warning', function () { .. })`. Which be handy in\nsome cases where you want to listen to all the events.\n\n`recovered` (null)\n\nEmitted when we have successfully recovered a old data file.\n\n### methods & properties\n\n`kju.push` () Arguments\n\nAdds the arguments to kju. Just like you would with a normal array.\n\n`kju.enable` (null)\n\nEnables kju, it sets the internal interval again and adds a listeners for\nprocess closing.\n\n`kju.disable` (nocommit) Boolean\n\nDisables kju and processes all internally queued data unless the `nocommit`\nargument has been set to true.\n\n`kju.forEach` (fn, that) Function, thisArg\n\nLoops over the current queued data, just like it would with a normal array.\n\n\n## License\n\nThe module is licensend under MIT, see the LICENSE file in the repository for\nmore information.\n","readmeFilename":"Readme.md"}