Archive for January, 2010
Another nosql project, mongodb provides more than just key-value pair storage. It is a document orientated database (along the lines of relational databases, but without a fixed structure for tables, or relational queries). That is, you can store objects (documents) that contain any combination of fields and data (data being strings, numbers, arrays or objects themselves), and then perform queries on them.
I have been interested in using mongo as a logging system for Ircster for a while now (it supports large sets of data with full text search and very fast queries), however until recently there was no reasonable driver for node. There are now two drivers available node-mongodb (bindings to the C driver) and node-mongodb-native (a JS implementation of the driver). The native driver especially interests me as I can more easily understand and work with the code.
I’ve been aware of a number of so called nosql projects (databases that aren’t relational) for some time and I finally have an opportunity to use one for a good reason.
Redis is an extremely fast key-value pair database (a hash table basically) that also includes fast, atomic set and list operations. I’m planning to use it as part of my group software project at uni, the project requires us to handle large amounts of data with a large number of requests per second, which makes 110,000 writes per second (one of the features of Redis) very appealing.
I’d also like to use my blog to write about a few of my personal projects. Many of these aren’t very useful and very few actually reach any usable state, however I feel node_debug is actually something quite useful.
Before reading this post you should probably know what node.js is.
node_debug allows you to evaluate statements and view their result (much like a REPL) from your favourite browser (assuming your favourite browser isn’t IE). It also allows you to browse objects if the result of your statement is an object, for example the global object in node is process
so executing process;
will return a browsable tree structure of the global scope.
Additionally it exports a log function that allows you to asynchronously output to any active console, for example setTimeout(function () { debug.log("Hello") }, 5000);
will output Hello to any open consoles after 5 seconds, allowing useful debug output when using asynchronous functions.
To get started using node_debug you need to have a server running node, and to grab the latest node_debug from github. There is an example.js included to show how you would include it in your own scripts, the idea being you can simply include this in your own project in order to easily debug issues.
Future features I would like to add include:
- A debug.scope object that allows you to import other objects into the debuggers scope (currently only the global scope is available which can cause confusion due to closures in JavaScript hiding a lot of variables from the debugger).
- debug.error/warn/info functions in line with the browser console object provided by firebug.
- Detect disconnection from node and attempt reconnection.
- Caching of asynchronous messages that can be shown when connecting to the console, in order to log things without having an active browser window all the time.