Skip to content

Commit

Permalink
Create gh-pages branch via GitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
jdarling committed Aug 3, 2012
0 parents commit c68ea22
Show file tree
Hide file tree
Showing 10 changed files with 1,063 additions and 0 deletions.
Binary file added images/code.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/pattern.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/tar.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/top.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/zip.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
361 changes: 361 additions & 0 deletions index.html

Large diffs are not rendered by default.

52 changes: 52 additions & 0 deletions javascripts/script.js
@@ -0,0 +1,52 @@
(function($) {
$(document).ready(function(){

// putting lines by the pre blocks
$("pre").each(function(){
var pre = $(this).text().split("\n");
var lines = new Array(pre.length+1);
for(var i = 0; i < pre.length; i++) {
var wrap = Math.floor(pre[i].split("").length / 70)
if (pre[i]==""&&i==pre.length-1) {
lines.splice(i, 1);
} else {
lines[i] = i+1;
for(var j = 0; j < wrap; j++) {
lines[i] += "\n";
}
}
}
$(this).before("<pre class='lines'>" + lines.join("\n") + "</pre>");
});

var headings = [];

var collectHeaders = function(){
headings.push({"top":$(this).offset().top - 15,"text":$(this).text()});
}

if($(".markdown-body h1").length > 1) $(".markdown-body h1").each(collectHeaders)
else if($(".markdown-body h2").length > 1) $(".markdown-body h2").each(collectHeaders)
else if($(".markdown-body h3").length > 1) $(".markdown-body h3").each(collectHeaders)

$(window).scroll(function(){
if(headings.length==0) return true;
var scrolltop = $(window).scrollTop() || 0;
if(headings[0] && scrolltop < headings[0].top) {
$(".current-section").css({"opacity":0,"visibility":"hidden"});
return false;
}
$(".current-section").css({"opacity":1,"visibility":"visible"});
for(var i in headings) {
if(scrolltop >= headings[i].top) {
$(".current-section .name").text(headings[i].text);
}
}
});

$(".current-section a").click(function(){
$(window).scrollTop(0);
return false;
})
});
})(jQuery)
1 change: 1 addition & 0 deletions params.json
@@ -0,0 +1 @@
{"name":"MongoMQ","google":"","tagline":"MongoMQ is a messaging queue built on top of Node.js and MongoDB's tailable cursors.","body":"MongoMQ - Node.js MongoMQ\r\n=========================\r\n\r\nVersion 0.2.4 introduces two new demo applications (basic and webserver) to showcase how to utilize MongoMQ. It made a minor change to the MongoMQ Constructor allowing for no options to be passed when working with a local MongoDB instance and not needing to specify a Database or Collection to utilize.\r\n\r\nThe webserver example was built using [WebMatrix 2.0](http://www.microsoft.com/web/webmatrix/) and is an example of a complete useable sample of how an application stack could be developed with MongoMQ. The idea is to have a webserver where the processing can take place anywhere else on the network or any place where the MongoDB is available. At the same time it could be ran in a load balanced solution where multiple copies of the stack are balanced and still share work. It uses MongoDB as the data store since it must already be available to use MongoMQ.\r\n\r\nThe code used for the webserver demo was modified from [Steven Sandersons video tutorials](https://github.com/SteveSanderson/nodejs-webmatrix-video-tutorials)\r\n\r\nInstallation\r\n============\r\n\r\nFrom GitHub\r\n-----------\r\n * Download from GitHub and extract.\r\n * npm install mongodb\r\n\r\nUsing NPM\r\n---------\r\n * npm install mongomq\r\n\r\nRequirements\r\n============\r\n * Node.js - v0.8.2 or better (really only for the MongoMQ and Test.js scripts REPL support)\r\n * MongoDB - v2.0.2 or better (for Tailable Cursors, autoIndexId bug fix, and ReplicaSet fixes)\r\n \r\nWhat is MongoMQ?\r\n================\r\n\r\nMongoMQ is a messaging queue built on top of Node.js and MongoDB's tailable cursors. It allows for distributed of messages across workers in both a single reciever and broadcast method.\r\n\r\nWhat MongoMQ is NOT\r\n===================\r\n\r\nMongoMQ does NOT (currently) support callback's once a message is processed. Instead it is recommended that you use a one time listener to pickup responses if this is required.\r\n\r\nSupported Methods\r\n=================\r\n\r\nnew MongoMQ(options)\r\n--------------------\r\noptions\r\n * mqCollectionName - Collection to store queue messages in, defaults to 'queue'\r\n * mqDB - Database to store queue in, defaults to 'MongoMQ'\r\n * username - Optional value of the username to validate against Mongo with\r\n * password - Optional value of the password to validate against Mongo with\r\n * server - If not running against a ReplicaSet this is the server to connect to\r\n * port - If not running against a ReplicaSet this is the server port to connect with\r\n * servers[] - If connecting to a ReplicaSet then this is a collection of {host: 'hostname', port: 1234} objects defining the root entry for the ReplicaSet\r\n * collectionSize - The size in bytes to cap the collection at, defaults to 100000000\r\n * serverOptions - An optional options object that will be passed to Mongo-Native when the Mongo connection is created\r\n * nativeParser - Boolean (defaults false) to enable usage of Mongo-Native's native parser. Only use this if you install mongodb with native support\r\n * autoStart - Boolean (defaults true) if the MongoMQ instance should start itself up when created, if set to false you need to call MongoMQ.start()\r\n\r\nMongoMQ.start([callback])\r\n-------------------------\r\n\r\nStarts the queue listener and sets up the emitter.\r\n\r\nParams:\r\n* callback - will be called once the queue is opened and all registered listeners are setup\r\n\r\nMongoMQ.stop([callback])\r\n------------------------\r\n\r\nStops listening for messages and closes the emitter.\r\n\r\nParams:\r\n* callback - will be called once the queue is completely close and all registered listeners have been shut down\r\n\r\nMongoMQ.emit(msgType, data, [partialCallback], [completeCallback])\r\n------------------------------------------------------------------\r\n\r\nPlaces the a message of msgTye on the queue with the provided data for handlers to consume.\r\n\r\nParams:\r\n* msgType - The message type to emit.\r\n* data - a JSON serializeable collection of data to be sent.\r\n* partialCallback - Will be called for large or long running result sets to return partial data back. Optional and if not present then completeCallback will be called with buffered results once all operations have completed.\r\n* completeCallback - Will be called once all remote processing has been completed. If partialCallback is not provided and completeCallback is provided a temporary buffer will be setup and the final result set will be sent to completeCallback.\r\n\r\nMongoMQ.on(msgType, [passive||options], handler)\r\n---------------------------------------\r\n\r\nSets up a listener for a specific message type.\r\n\r\nParams:\r\n* msgType - The message type to listen for can be a string or a regular expression\r\n* passive - If true will not mark the message as handled when a message is consumed from the queue\r\n* options - additional options that can be passed\r\n* handler(err, messageContents, next) - Use next() to look for another message in the queue, don't call next() if you only want a one time listener\r\n * If you want to send back data or partial data use next(data, complete) where complete should be true if you have sent all of your responses, see test.js r.context.tmp for a simple example.\r\n\r\noptions -\r\n * passive - If true will not mark the message as handled when a message is consumed from the queue\r\n * hereOnOut - Boolean (defaults false) will only recieve messages from the time the listener was registered instead of all unconsumed messages if set to true\r\n\r\n\r\nMongoMQ.onAny(handler)\r\n----------------------\r\n\r\nSets up a passive listener for all messages that are placed on the queue.\r\n\r\nParams:\r\n* callback(err, messageContents, next) - Use next() to look for another message in the queue, don't call next() if you only want a one time listener\r\n\r\nMongoMQ.indexOfListener([event], [handler])\r\n-------------------------------------------\r\n\r\nProvides back the index of the first listener that matches the supplied event and/or handler. One or both of event and handler must be supplied. Returns BOOLEAN false if no handler is found.\r\n\r\nParams:\r\n* event - The name of the event to look for.\r\n* handler - The specific handler function to look for.\r\n\r\nMongoMQ.getListenerFor([event], [handler])\r\n------------------------------------------\r\n\r\nProvides back the first listener that matches the supplied event and/or handler. One or both of event and handler must be supplied. Returns BOOLEAN false if no handler is found.\r\n\r\nParams:\r\n* event - The name of the event to look for.\r\n* handler - The specific handler function to look for.\r\n\r\nMongoMQ.removeListener([event], [handler])\r\n------------------------------------------\r\n\r\nShuts down the first listener that matches the supplied event and/or handler and removes it from the listeners list.\r\n\r\nParams:\r\n* event - The name of the event to look for.\r\n* handler - The specific handler function to look for.\r\n\r\nMongoMQ.removeListeners(event)\r\n------------------------------\r\n\r\nShuts down ALL listeners for the specified event and removes it from the listeners list.\r\n\r\nParams:\r\n* event - The name of the event to look for.\r\n\r\nMongoMQ.removeAllListeners()\r\n----------------------------\r\n\r\nShuts down ALL listeners and clears the listeners list.\r\n\r\nHow does MongoMQ work?\r\n======================\r\n\r\nMongoMQ sets up a tailable collection and then starts listeners using find in conjunction with findAndModify to pickup messages out of this collection.\r\n\r\nSince MongoMQ is basically a wrapper around MongoDB's built in support for tailable cursors it is possible to place listeners built in other langauges on the \"queue\".\r\n\r\nSample Usage\r\n============\r\n\r\n * Ensure MongoDB is up and running locally (or modify the config options to collect to your Mongo instance)\r\n * Start 3 copies of the bin/test.js script.\r\n * In two copies type listen() to setup a \"test\" message listener\r\n * In the 3rd copy type load() to send 100 test messages to the queue\r\n \r\nYou should see the two listeners pickup messages one at a time with whoever has resources to process picking up the message first.\r\n\r\nbin/test.js\r\n===========\r\n\r\n```javascript\r\nvar MongoMQ = require('../lib/MongoMQ').MongoMQ;\r\nvar repl = require('repl');\r\n\r\nvar queue = new MongoMQ({\r\n autoStart: false\r\n});\r\n\r\nvar r = repl.start({\r\n prompt: \"testbed>\"\r\n });\r\nr.on('exit', function(){\r\n queue.stop();\r\n});\r\n\r\nvar msgidx = 0;\r\nr.context.send = function(){\r\n queue.emit('test', msgidx);\r\n msgidx++;\r\n};\r\n\r\nr.context.load = function(){\r\n for(var i = 0; i<100; i++){\r\n queue.emit('test', msgidx);\r\n msgidx++;\r\n }\r\n};\r\n\r\nvar logMsg = function(err, data, next){\r\n console.log('LOG: ', data);\r\n next();\r\n };\r\nvar eatTest = function(err, data, next){\r\n console.log('eat: ', data);\r\n next();\r\n };\r\n\r\nr.context.logAny = function(){\r\n queue.onAny(logMsg);\r\n};\r\n\r\nr.context.eatTest = function(){\r\n queue.on('test', eatTest);\r\n};\r\n\r\nr.context.start = function(cb){\r\n queue.start(cb);\r\n};\r\n\r\nr.context.stop = function(){\r\n queue.stop();\r\n};\r\n\r\nr.context.help = function(){\r\n console.log('Built in test methods:\\r\\n'+\r\n ' help() - shows this message\\r\\n'+\r\n ' logAny() - logs any message to the console\\r\\n'+\r\n ' eatTest() - consumes next available \"test\" message from the queue\\r\\n'+\r\n ' send() - places a \"test\" message on the queue\\r\\n'+\r\n ' load() - places 100 \"test\" messages on the queue\\r\\n'+\r\n ' start() - start the queue listener\\r\\n'+\r\n ' stop() - stop the queue listener\\r\\n'+\r\n '\\r\\nInstance Data\\r\\n'+\r\n ' queue - the global MongoMQ instance\\r\\n'\r\n );\r\n return '';\r\n};\r\n\r\n/*\r\nqueue.start(function(){\r\n r.context.eatTest();\r\n});\r\n*/\r\n\r\nr.context.queue = queue;\r\n\r\nr.context.help();\r\n```\r\n\r\nHow Events are stored\r\n=====================\r\n\r\n```javascript\r\n{\r\n _id: ObjectId(), // for internal use only\r\n event: 'event name', // string that represents what type of event this is\r\n data: JSON Data, // Contains the actual message contents\r\n handled: boolean, // states if the message has been handled or not\r\n emitted: Date(), // Contains the date/time when the event was emitted\r\n partial: boolean, // for responses states if this is a partial response or the complete/end response\r\n host: string, // Contains the host name of the machine that initiated the event\r\n conversationId: string // if the event expects response(s) this will be the conversation identifier used to track those responses\r\n}\r\n```\r\n\r\nUpdate History\r\n==============\r\n\r\nv0.2.4\r\n * Modified MongoMQ constructor to allow for no options to be passed\r\n * Added basic and webserver examples\r\n * Move ensureCappedCollection logic to MongoConnection where it belongs\r\n * Surfaced MongoConnection from the main library in case anyone else wants to use it, also used in webserver demo\r\n\r\nv0.2.3\r\n * Minor bug fix related to passive listeners where a fromDT was not passed in the options\r\n * Added hostName to messages for better tracking/logging\r\n * Modified passive callback to pass the actual message as the \"this\" argument, you can now use this.event to get the actual event that was responded to\r\n * Updated the on() method to accept strings or regular expressions to filter events on\r\n\r\nv0.2.2\r\n * Completed code to allow for callbacks and partial callbacks to be issued back to emit statements\r\n * Complteed refactoring of code to properly seperate functionality into objects\r\n\r\nv0.2.1\r\n * Majorly refactored code\r\n * Added autoIndexId: true to queue collection creation\r\n * Better MongoMQ application with help()\r\n * Updated test application\r\n * Added an exception to emit() when you try to emit before start() has been called\r\n * fix to onAny so it will restart listeners after a close() and start() re-issue\r\n * Added remove*() methods\r\n * Changed close() to stop()\r\n * hereOnOut options - allows listeners to only pay attention to messages posted after they have been started up\r\n * Added ability to register listeners (via on and onAny) when queue is not started\r\n\r\nv0.1.1\r\n * Bug fixes to on event\r\n * Added in new onAny register\r\n * Migrated code to retain cursor\r\n \r\nv0.1.0\r\n * Initial release\r\n * More of a proof of concept\r\n","note":"Don't delete this file! It's used internally to help with page regeneration."}
69 changes: 69 additions & 0 deletions stylesheets/pygment_trac.css
@@ -0,0 +1,69 @@
.highlight { background: #ffffff; }
.highlight .c { color: #999988; font-style: italic } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { font-weight: bold } /* Keyword */
.highlight .o { font-weight: bold } /* Operator */
.highlight .cm { color: #999988; font-style: italic } /* Comment.Multiline */
.highlight .cp { color: #999999; font-weight: bold } /* Comment.Preproc */
.highlight .c1 { color: #999988; font-style: italic } /* Comment.Single */
.highlight .cs { color: #999999; font-weight: bold; font-style: italic } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .gd .x { color: #000000; background-color: #ffaaaa } /* Generic.Deleted.Specific */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #999999 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .gi .x { color: #000000; background-color: #aaffaa } /* Generic.Inserted.Specific */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #800080; font-weight: bold; } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { font-weight: bold } /* Keyword.Constant */
.highlight .kd { font-weight: bold } /* Keyword.Declaration */
.highlight .kn { font-weight: bold } /* Keyword.Namespace */
.highlight .kp { font-weight: bold } /* Keyword.Pseudo */
.highlight .kr { font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #445588; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #009999 } /* Literal.Number */
.highlight .s { color: #d14 } /* Literal.String */
.highlight .na { color: #008080 } /* Name.Attribute */
.highlight .nb { color: #0086B3 } /* Name.Builtin */
.highlight .nc { color: #445588; font-weight: bold } /* Name.Class */
.highlight .no { color: #008080 } /* Name.Constant */
.highlight .ni { color: #800080 } /* Name.Entity */
.highlight .ne { color: #990000; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #990000; font-weight: bold } /* Name.Function */
.highlight .nn { color: #555555 } /* Name.Namespace */
.highlight .nt { color: #000080 } /* Name.Tag */
.highlight .nv { color: #008080 } /* Name.Variable */
.highlight .ow { font-weight: bold } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mf { color: #009999 } /* Literal.Number.Float */
.highlight .mh { color: #009999 } /* Literal.Number.Hex */
.highlight .mi { color: #009999 } /* Literal.Number.Integer */
.highlight .mo { color: #009999 } /* Literal.Number.Oct */
.highlight .sb { color: #d14 } /* Literal.String.Backtick */
.highlight .sc { color: #d14 } /* Literal.String.Char */
.highlight .sd { color: #d14 } /* Literal.String.Doc */
.highlight .s2 { color: #d14 } /* Literal.String.Double */
.highlight .se { color: #d14 } /* Literal.String.Escape */
.highlight .sh { color: #d14 } /* Literal.String.Heredoc */
.highlight .si { color: #d14 } /* Literal.String.Interpol */
.highlight .sx { color: #d14 } /* Literal.String.Other */
.highlight .sr { color: #009926 } /* Literal.String.Regex */
.highlight .s1 { color: #d14 } /* Literal.String.Single */
.highlight .ss { color: #990073 } /* Literal.String.Symbol */
.highlight .bp { color: #999999 } /* Name.Builtin.Pseudo */
.highlight .vc { color: #008080 } /* Name.Variable.Class */
.highlight .vg { color: #008080 } /* Name.Variable.Global */
.highlight .vi { color: #008080 } /* Name.Variable.Instance */
.highlight .il { color: #009999 } /* Literal.Number.Integer.Long */

.type-csharp .highlight .k { color: #0000FF }
.type-csharp .highlight .kt { color: #0000FF }
.type-csharp .highlight .nf { color: #000000; font-weight: normal }
.type-csharp .highlight .nc { color: #2B91AF }
.type-csharp .highlight .nn { color: #000000 }
.type-csharp .highlight .s { color: #A31515 }
.type-csharp .highlight .sc { color: #A31515 }

0 comments on commit c68ea22

Please sign in to comment.