Permalink
Browse files

2011-04-16 WebWorkersCamp 3

  • Loading branch information...
1 parent d916436 commit e027e6c89ac96ceb15a057fb79adbe4ec8791365 @nono committed Apr 18, 2011
@@ -0,0 +1,66 @@
+!SLIDE
+# Ruby 1.9 et les fibres #
+
+```ruby
+def async_fetch(url)
+ f = Fiber.current
+ http = EM::HttpRequest.new(url).get :timeout => 10
+ http.callback { f.resume(http) }
+ http.errback { f.resume(http) }
+ return Fiber.yield
+end
+
+EM.run do
+ Fiber.new {
+ data = async_fetch('http://www.google.com/')
+ puts "Fetched page #1: #{data.response_header.status}"
+ EM.stop
+ }.resume
+end
+```
+
+!SLIDE
+# EM-Synchrony : exemple #
+
+```ruby
+EM.synchrony do
+ multi = EM::Synchrony::Multi.new
+ multi.add :page1, EM::HttpRequest.new("http://service.com/page1").aget
+ multi.add :page2, EM::HttpRequest.new("http://service.com/page2").aget
+ multi.add :page3, EM::HttpRequest.new("http://service.com/page3").aget
+ data = multi.perform.responses[:callback].values
+end
+```
+
+!SLIDE
+# EM-Synchrony : exemple (suite) #
+
+```ruby
+EM.synchrony do
+ data = ["Données de l'exemple précédent"]
+ db = EM::Synchrony::ConnectionPool.new(size: 4) do
+ EM::MySQL.new(host: "localhost")
+ end
+ EM::Synchrony::Iterator.new(data, 2).each do |page, iter|
+ db.aquery("INSERT INTO table (data) VALUES(#{page});")
+ db.callback { iter.return(http) }
+ end
+end
+```
+
+!SLIDE
+# Goliath et EM-Synchrony #
+
+```ruby
+require 'goliath'
+require 'em-synchrony/em-http'
+
+class HelloWorld < Goliath::API
+ def response(env)
+ req = EM::HttpRequest.new("http://www.google.com/").get
+ resp = req.response
+ [200, {}, resp]
+ end
+end
+```
+
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,53 @@
+!SLIDE
+# EventMachine #
+
+* Framework Ruby
+* Evented
+* Des drivers réseaux
+ * (http, mysql, redis, MongoDB, SMTP, AMQP, XMPP and many more)
+
+!SLIDE
+# 1 processus par connexion #
+![Fast Food](mcdo.jpg)
+
+!SLIDE center
+# 1 thread par connexion #
+![Credit Card](card.jpg)
+
+!SLIDE center
+# Modèle événementiel #
+![Japonais](jap.jpg)
+
+!SLIDE
+# EventMachine : Exemple #
+
+```ruby
+#!/usr/bin/env ruby
+require 'eventmachine'
+
+EM.run do
+ EM.add_periodic_timer(1) { puts "Tick ..." }
+ EM.add_timer(5) { EM.stop_event_loop }
+end
+
+puts "Fini"
+```
+
+!SLIDE
+# Goliath et EventMachine #
+
+```ruby
+class Stream < Goliath::API
+ def response(env)
+ i = 0
+ pt = EM.add_periodic_timer(1) do
+ env.stream_send("#{i += 1} ")
+ end
+ EM.add_timer(10) do
+ pt.cancel
+ env.stream_close
+ end
+ [200, {}, Goliath::Response::STREAMING]
+ end
+end
+```
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,21 @@
+!SLIDE
+# Goliath : le reste #
+
+* Plusieurs modes : dev / test / prod
+* Configuration par environnement
+* Les plugins : du code EventMachine
+* Le `runner` et ses options
+* ...
+
+!SLIDE
+# Goliath : le futur #
+
+* Cloud Foundry
+* Websockets (en cours)
+* SPDY ?
+* Interface à la Sinatra/Grape ?
+
+!SLIDE
+# Goliath #
+## Conclusion ##
+
@@ -0,0 +1,29 @@
+!SLIDE
+# Node.js #
+## /!\\ Attention /!\\ ##
+Ça va troller...
+
+!SLIDE
+# Node.js : défauts #
+
+1. Pas prêt
+2. Code difficile à relire
+
+!SLIDE
+# Node.js : pas prêt #
+
+* Manque de bibliothèque standard
+ * (base64, yaml, logging, mails)
+* API pas stable
+* Memory leaks
+* Toujours pas de Webworkers
+
+!SLIDE
+# Node.js : code illisible #
+
+1. Callbacks avec de nombreuses indentations
+2. Callbacks nommés, mais avec de nombreux arguments
+3. Passer les arguments avec `this`
+
+**=> Code difficile à tester**
+
@@ -5,9 +5,9 @@
"intro",
"rack",
"eventmachine",
- "goliath",
+ "nodejs",
"em-synchrony",
- "advanced_examples",
+ "goliath",
"questions"
]
}
@@ -1,14 +1,12 @@
!SLIDE
-# Le reste #
-
-* Plusieurs modes : dev / test / prod
-* Configuration par environnement
-* Les plugins : du code EventMachine
-* Le `runner` et ses options
-* ...
+# That's all folks #
+## Questions ? ##
+!SLIDE #end
+# Credits #
-!SLIDE
-# That's all folks #
+* http://www.flickr.com/photos/consumerist/614672919/
+* http://www.flickr.com/photos/nzbuu/3314624297/
+* http://www.flickr.com/photos/wakelucid/4760639193/
-## Questions ? ##
+Slides on [github.com/nono/Presentations](http://github.com/nono/Presentations)
@@ -66,6 +66,7 @@ end
require "goliath"
class Hello < Goliath::API
+ use Rack::ContentLength
def response(env)
[200, {}, "Hello World!"]
end
View
@@ -14,7 +14,7 @@ And they should run with [slide'em up](https://github.com/nono/slide-em-up) soon
* 2011-02-08 - [TechDays](http://www.microsoft.com/france/mstechdays/) - [JavaScript dans tous ses états](https://github.com/abolibibelot/Techdays2011_Javascript) (in french)
* 2011-02-09 - [TechDays](http://www.microsoft.com/france/mstechdays/) - 45 projects in 45 minutes
* 2011-04-15 - [WebWorkersCamp3](http://barcamp.org/w/page/36708944/WebWorkersCamp3) - [20 projects in 20 minutes](http://wwc3-20-projects.heroku.com/)
-* 2011-04-16 - [WebWorkersCamp3](http://barcamp.org/w/page/36708944/WebWorkersCamp3) - Goliath et ses amis
+* 2011-04-16 - [WebWorkersCamp3](http://barcamp.org/w/page/36708944/WebWorkersCamp3) - [Goliath et ses amis](http://nono.github.com/Presentations/20110416_Goliath/)
Contact

0 comments on commit e027e6c

Please sign in to comment.