2. Continuity
A continuation based web application
library for perl.
Brock Wilcox (awwaiid@thelackthereof.org)
Pittsburgh Perl Workshop 2007
http://continuity.tlt42.org/
3. Talk Overview
● Traditional Web Apps
● Continuation Based Web Apps
● Seaside
● Continuity
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. 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
8. Run Lola Run
● Capture a moment in time
● Put it in a variable
● Execute it later
● Execute it again?
● Welcome to Continuations
9. Continuation Conshminuation
● Program state in a variable
– Not just data! Control flow too!
● One-shot vs Multi-shot
● Coroutines
● Cooperative Multithreading
10. Continuations in Web Apps
● Don't restart app
● Continue on source next line
● Keep program state (local vars)
● Centralize control flow logic
11. Other Efforts
● ViaWeb (Lisp, Paul Grahm 1999)
● Seaside (Smalltalk)
● UnCommon Web, SISCweb (Scheme)
● RIFE (Java)
● ... AJAX Turns Things Inside Out Too ...
19. Coro
● Written by Marc Lehmann
● Coroutines for Perl
● Saves
– callchain
– lexical variables
– @_ $_ $@ $/
– C stack
● Effectively one-shot continuations
● Plus other goodies!
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. Detect the Back Button
● Send a unique Request ID
● Duplicates imply Back, Reload, or Fork
● Set flag, raise exception, ignore
30. Bookmarks
● Bring back the CASE statement
● Goto the right spot :)
● Continue from there
● URLs for major parts of application
31. Security
● Easy to centralize Input and Output
● Guessing a ContinuationID is bad
32. Scalability
● Difficult to scale?
● Serve dynamic data (not static stuff)
● Session Affinity
● Don't fix it if it ain't broke
33. Advanced Techniques
● Subref callbacks
● Multiple continuations per session
● Event.pm timers and watchers