PPW2007 - Continuity Project

988 views

Published on

See http://continuity.tlt42.org/ for more information.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
988
On SlideShare
0
From Embeds
0
Number of Embeds
23
Actions
Shares
0
Downloads
17
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

PPW2007 - Continuity Project

  1. 1. cgi programs rise from ash then burn again upon each request
  2. 2. Continuity A continuation based web application library for perl. Brock Wilcox (awwaiid@thelackthereof.org) Pittsburgh Perl Workshop 2007 http://continuity.tlt42.org/
  3. 3. Talk Overview ● Traditional Web Apps ● Continuation Based Web Apps ● Seaside ● Continuity
  4. 4. Memento
  5. 5. Memento ● Do an action ● What did I just do? Ask the requestor ● What did I just do? Look for a sticky note (cookie)
  6. 6. CGI Applications ● Restart on each request ● Start with a switch statement ● GOTO based on input ● Control flow logic spread out ● Switch statement is state machine
  7. 7. Run Lola Run
  8. 8. Run Lola Run ● Capture a moment in time ● Put it in a variable ● Execute it later ● Execute it again? ● Welcome to Continuations
  9. 9. Continuation Conshminuation ● Program state in a variable – Not just data! Control flow too! ● One-shot vs Multi-shot ● Coroutines ● Cooperative Multithreading
  10. 10. Continuations in Web Apps ● Don't restart app ● Continue on source next line ● Keep program state (local vars) ● Centralize control flow logic
  11. 11. Other Efforts ● ViaWeb (Lisp, Paul Grahm 1999) ● Seaside (Smalltalk) ● UnCommon Web, SISCweb (Scheme) ● RIFE (Java) ● ... AJAX Turns Things Inside Out Too ...
  12. 12. Seaside
  13. 13. Overview of Seaside ● Continuations ● No templates ● Components ● Generated HTML with callbacks
  14. 14. Seaside Demo ● Counter example ● Halos ● In-page code browser ● Inline link-press callbacks
  15. 15. This is SWEET
  16. 16. I want this in Perl
  17. 17. Continuations in Perl5 ● Nothing built-in ● High-level trickery (Contize) ● Low-level trickery (Coro) ● Other trickery? ● use v6;
  18. 18. use Coro;
  19. 19. Coro ● Written by Marc Lehmann ● Coroutines for Perl ● Saves – callchain – lexical variables – @_ $_ $@ $/ – C stack ● Effectively one-shot continuations ● Plus other goodies!
  20. 20. Continuity
  21. 21. Continuity ● Keep a list of continuations ● Accept incoming HTTP requests ● Map to a continuation ● Repeat
  22. 22. Continuity Design ● Library Not Framework ● Unobtrusive ● TMTOWTDI ● Foundation for higher abstraction ● Modular – Plugable Adaptors: HttpDaemon, FastCGI, ... – Session Mapper
  23. 23. What is it Good For ● High interaction ● Shared state - games ● Command line conversions ● Clean, organized code
  24. 24. Continuation Mapping ● Incoming request to continuation – Cookie – IP – Path – Query ● Path + Cookie is fun ● Query is my favorite
  25. 25. Counter Example ● Demonstrates: – Server setup – Cookie sessions – Query sessions – Parameters – Input loop – Subroutines if we make a prompt
  26. 26. Chat Example ● Demonstrates – All things as Counter Example – AJAX and COMET – Multi-Continuation Sessions
  27. 27. Issues ● Back Button ● Bookmarks ● Security ● Scalability
  28. 28. Back Buttons and Bookmarks ● URLs should be pretty ● Many techniques to choose from ● Continuity doesn't decide for you ● Seaside mostly gives up, uses Request ID
  29. 29. Detect the Back Button ● Send a unique Request ID ● Duplicates imply Back, Reload, or Fork ● Set flag, raise exception, ignore
  30. 30. Bookmarks ● Bring back the CASE statement ● Goto the right spot :) ● Continue from there ● URLs for major parts of application
  31. 31. Security ● Easy to centralize Input and Output ● Guessing a ContinuationID is bad
  32. 32. Scalability ● Difficult to scale? ● Serve dynamic data (not static stuff) ● Session Affinity ● Don't fix it if it ain't broke
  33. 33. Advanced Techniques ● Subref callbacks ● Multiple continuations per session ● Event.pm timers and watchers
  34. 34. Future Work ● Get people using it ● Feedback!
  35. 35. Future Work ● High-level layer(s) on top ● Continuity + Moose + DBIx::Class ● Steal from Seaside ● Steal from Magritte ● Steal from everyone
  36. 36. Future Work ● Easy DBI interface – Coro::Util::eval_fork ● Other languages, keep similar minimal API
  37. 37. Get it on CPAN.
  38. 38. The End

×