Permalink
Browse files

Readme tweaks.

  • Loading branch information...
1 parent 0051e19 commit b519177bbd4cab472b8e04a9cd608e21fc7d91da @benzenwen benzenwen committed Mar 23, 2012
Showing with 34 additions and 25 deletions.
  1. +19 −10 README.md
  2. +14 −14 app.js
  3. +1 −1 index.html
View
@@ -1,32 +1,41 @@
# Tractor Push
-This is a demonstration of a socket.io client that accepts two message streams from a server asynchronously. The left box updates on the arrival of the 'all messages' stream: simple, array, or complex. The right box updates from a message stream of only 'complex' type. The streams are independent but draw from the same source.
-A running version of the demo is at: TODO ADD URL
+This is a demonstration of a socket.io client that accepts two message
+streams from a server asynchronously. The left box updates on the
+arrival of the 'all messages' stream: simple, array, or complex. The
+right box updates from a message stream of only 'complex' type. The
+streams are independent but draw from the same source.
-The server is node.js running socket.io. It reads from a capped MongoDB database with a tailable cursor. A secondary set of servers (it happens to be in Ruby) originally wrote to the database.
+A running version of the demo is at: http://tractorpush.herokuapp.com
+
+The server is node.js running socket.io. It reads from a capped
+MongoDB database with a tailable cursor. A secondary set of servers
+(it happens to be in Ruby) writes to the database.
Note: Sequence numbers may not be unique.
-In the online demo, the node.js and Ruby components are running on Heroku's Celedon Cedar stack. The MongoDB database is hosted at MongoLab. See this URL 'TODO: add URL' for more information.
+In the online demo, the node.js and Ruby components are running on
+Heroku's Celedon Cedar stack. The MongoDB database is hosted at
+MongoLab. See https://github.com/mongolab/tractorpush-server and https://github.com/mongolab/tractorpush-writer-ruby for more information.
# HOWTO
+
See: (TODO: URL) for detailed instructions on how to run the demo, but succintly:
+
* Create a mongodb database 'testdatabase' with a capped collection 'messages' on localhost OR use Heroku and create a MONGOLAB database.
-* Run tractorpush-inserter-ruby to insert files TODO NEED URL
+* Run tractorpush-inserter-ruby to insert files
* Run 'npm install' Run tractorpush-server (this project): 'node.js app.js'
* Point your browser to http://localhost:2000 and enjoy
# Inserter Ruby
-The insertion code is at https://github.com/mongolab/tractorpush-inserter-ruby
+The insertion code is at https://github.com/mongolab/tractorpush-writer-ruby
+
+# Server REQUIRES
-# REQUIRES (ok, it may run with something less)
* Node.js 0.6.9 +
* npm 1.1.0-3
* see package.json for more dependencies (socket.io and mongodb)
-# TODO
-* Make this demo more obvious what to do if a newbie (or a pointer to the blog entry).
-* Make this demo server insert one document if it finds a blank database (which means creating a capped collection.) or at least send a reasonable message to the user somehow.
Original Demo: 2012 March by ObjectLabs Corporation, makers of MongoLab.com hosted MongoDB.
View
@@ -13,17 +13,17 @@
//
- // Licensed under the Apache License, Version 2.0 (the "Apache License");
- // you may not use this file except in compliance with the Apache License.
- // You may obtain a copy of the License at
- //
- // http://www.apache.org/licenses/LICENSE-2.0
- //
- // Unless required by applicable law or agreed to in writing, software
- // distributed under the Apache License is distributed on an "AS IS" BASIS,
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- // See the Apache License for the specific language governing permissions and
- // limitations under the Apache License.
+// Licensed under the Apache License, Version 2.0 (the "Apache License");
+// you may not use this file except in compliance with the Apache License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the Apache License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the Apache License for the specific language governing permissions and
+// limitations under the Apache License.
//
// NB: I don't provide a durable connection to mongodb that retries on
@@ -104,17 +104,17 @@ function startIOServer (collection) {
io.set("log level", 2);
});
io.sockets.on('connection', function (socket) {
- queriedSend(socket, collection);
+ readAndSend(socket, collection);
});
};
//
-// Find and send data to socket.
+// Read and send data to socket.
// The real work is done here upon receiving a new client connection.
// Queries the database twice and starts sending two types of messages to the client.
// (known bug: if there are no documents in the collection, it doesn't work.)
//
-function queriedSend (socket, collection) {
+function readAndSend (socket, collection) {
collection.find({}, {'tailable': 1, 'sort': [['$natural', 1]]}, function(err, cursor) {
cursor.intervalEach(300, function(err, item) { // intervalEach() is a duck-punched version of each() that waits N milliseconds between each iteration.
if(item != null) {
View
@@ -135,7 +135,7 @@
This is a demonstration of a socket.io client that accepts two message streams from a server asynchronously. The left box updates on the arrival of the 'all messages' stream: simple, array, or complex. The right box updates from a message stream of only 'complex' type. The streams are independent but draw from the same source.
<p> The server is node.js running socket.io. It reads from a capped MongoDB database with a tailable cursor. A secondary set of servers (it happens to be in Ruby) originally wrote to the database.
<p> Note: Sequence numbers may not be unique.
-<p> The node.js and Ruby components are running on Heroku's Celedon Cedar stack. The MongoDB database is hosted at MongoLab. See this URL 'TODO: add URL' for more information.
+<p> The node.js and Ruby components are running on Heroku's Celedon Cedar stack. The MongoDB database is hosted at MongoLab. https://github.com/mongolab/tractorpush-server for more information.
<p> Original Demo: 2012 March
<p> LICENSE Code licensed under the Apache License, Version 2.0 (the "Apache
License"); you may not use this file except in compliance with

0 comments on commit b519177

Please sign in to comment.