node.js dao
Upcoming SlideShare
Loading in...5
×
 

node.js dao

on

  • 4,116 views

This presentation from my speech about node.js in miniq club.

This presentation from my speech about node.js in miniq club.

Statistics

Views

Total Views
4,116
Views on SlideShare
4,105
Embed Views
11

Actions

Likes
3
Downloads
28
Comments
0

2 Embeds 11

http://www.linkedin.com 10
https://www.linkedin.com 1

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

node.js dao node.js dao Presentation Transcript

  • node.js dao Vova Miguro
  • What’s it all about?
  • Node.js is a platform built onChrome’s JavaScript runtime foreasily building fast, scalablenetwork applications. -nodejs.org
  • How?Let’s keep slow operationsfrom blocking otheroperations.
  • traditional I/Ovar data = file.read(‘image.png’);//zzz...doSomething(data); something not right here...
  • async I/Ofile.read(‘image.png’,function(data){ doSomething(image);});doSomethingElse(); profit!
  • callback() callback()callback()
  • node.js internals• v8 (yeah, it’s Chrome’s engine)• libev (event loop)• libeio (asynchronous version of POSIX API)
  • it is only one thread!file.read(‘file.txt’,function(data){ //will never fire...})while(true){ //blocking entire process}
  • http servervar http = require(http);http.createServer(function (req, res) { res.writeHead(200, {Content-Type: text/plain}); res.end(Hello Worldn);}).listen(3000);
  • watch filevar fs = require(fs);fs.watchFile(system.log,function () { console.log(log changed!);});
  • node & mongovar mongodb = require(mongodb);var server = new Server(127.0.0.1, 27017, {});new Db(test, server, {}).open(function (error, client) { var collection = new Collection(client, tmp); //insert doc collection.insert({a:12,b:string},{},function(){ //find doc collection.find({}, {limit:10}).toArray(function(err, docs) { //do smth with docs }); });
  • node & web sockets//servervar io = require(socket.io).listen(80);io.sockets.on(connection, function (socket) { socket.emit(news, {hello:world});});//clientvar socket = io.connect(http://localhost);socket.on(news, function (data) { console.log(data);});
  • let’s see...
  • suited for...• real time• streaming• process monitoring• JSON API’s
  • do not use for this...
  • do not use for this...• CPU heavy apps• data transformation
  • ?