/
Continuations continued:the REST of the computationAnton van Straatena Continuations continued:the REST of the computationAnton van Straatena

Continuations continued:the REST of the computationAnton van Straatena - PDF document

jane-oiler
jane-oiler . @jane-oiler
Follow
398 views
Uploaded On 2016-03-08

Continuations continued:the REST of the computationAnton van Straatena - PPT Presentation

Fielding restdiscussproperties like scalability maintain application state on the server between requests dont really understand what the web is for anonymous Why does it matterREST guide ID: 247815

Fielding." rest-discussproperties like scalability maintain

Share:

Link:

Embed:

Download Presentation from below link

Download Pdf The PPT/PDF document "Continuations continued:the REST of the ..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Continuations continued:the REST of the computationAnton van Straatenappsolutions.com1 Fielding." -- rest-discussproperties, like scalability maintain application state on the server between requests don't really understand what the web is for" -- anonymous Why does it matter?REST guidelines well-proven - ignore at own riskContinuation-based web systems increasingly popularApplication spaces overlapWorth understanding apparent conflictUnderstand where first-class continuation use might be problematicBroaden the dialogue about continuations in practical contextsGet new ideas!5 by Roy Fielding."October 1994 and August 1995, primarily as a means forcommunicating Web concepts as we wrote the HTTP/1.0specification and the initial HTTP/1.1 proposal."an image of how a well-designed Web application behaves: anetwork of web pages (a virtual state-machine), where the userprogresses through the application by selecting links (statetransitions), resulting in the next page (representing the next stateof the application) being transferred to the user and rendered fortheir use." Major REST componentsData elementsResource : the intended conceptual target of a hypertextResource identifier : URL, URNRepresentation : XML or HTML document, JPEG imageComponentsorigin server : Apache httpd, Microsoft IISuser agents: Mozilla, IE, etc.other client programsgateways, proxies, and caches7 client's perception of resources, scales well with large numbers ofclients, enables transfer of data in streams of unlimited size andtype, supports intermediaries (proxies and gateways) as datatransformation and caching components, and concentrates theapplication state within the user agent components." protocol standards."guide to understanding the design trade-offs, why they were made,and what properties we lose when an implementation violates continuations: the "statelessness" constrainttheoretically a broader model.on distributed applications, with an expedient focus on web Continuation-based web systemsLisp - ViaWeb, UnCommon WebScheme - PLT, SISC, Chicken, PS3ISmalltalk - SeasideJavascript/Java - Apache CocoonPython - ImpostorRuby - BorgesHacksJava - ATCT, RIFEPerl: Continuity, Contize, Coro11 straightforward. In comparison, web app frameworks in the Javaworld, such as JSP or Struts, and even Ruby on Rails look like anything to do with it and brought it to Cocoon is a F#$%INGevery single day, preaching for my soul, to be, at one day, ofcomparable intelligence with his...out of me? Now I won't be able to design any web application withoutit! And that's the beautiful part of it!:-)" REST & abstract continuationsForget first-class continuations -Do abstract continuations apply to REST?If not, continuations as an abstraction are suspect.Is something else needed - pi calculus?Would be unfortunate:Continuations have gained mindshareAlready present in real tools14 Analyzing REST control flowIdentify the abstract continuations in RESTFigure out whether reifying them is of any use15 Abstract case is obviousEvery request involves continuationsRequest is a continuation in actionServer sends continuation(s) to client in every representationExample of continuation embedded in code sent to client: hr;ï=";&#xhttp;&#x://w;&#xww.e;&#xxamp;&#xle.c;&#xom/w;&#xidge;&#xt/35;"00;&#x/a00;Simple, but key concept16 orm;&#x act;&#xion=;&#x"htt;&#xp://;&#xwww.;xam;&#xple.; om/;&#xwidg;t" ;&#xmeth;&#xod=";&#xPOST;&#x"000; type="text" name="item-no" &#xinpu;&#xt-2.;ᝩ / name="description" &#xinpu;&#xt ty;&#xpe=";&#xtext;&#x"000;/ value="relevant stuff" &#xinpu;&#xt ty;&#xpe=";&#xhidd;n" ;&#xname;&#x="in;&#xtern; l"0;/ ...&#x/for;&#xm000; lambda ))))))))) Analysis of Case #1Continuation is serialized in representationBut not a value of type 'continuation' in host language(could be considered such in HTML)Conceptualizing as continuation is usefulBetter abstraction from underlying mechanism19 information necessary to understand the request, and cannottake advantage of any stored context on the server. Sessionstate is therefore kept entirely on the client." but not return-address information. A continuation needs both." -- Guy Steele, ll-discuss Case #3: send/suspend/dispatchIdiom & function by Pete HopkinsSupports providing multiple URIs to clientEach URI associated with closureSee also Waterken's Web CalculusReal, REST-compatible, first-class continuationsBut faked via closures - local CPS style22 define lambda lambda ((((lambda )))))((lambda )))))))))))))) Multiple control views of a distributed system(informal)Server control flowClient control flowClient/server control flowClient invokes function on serverFunction springs to life & executesTerminates with result and continuation(s)24 components together interconnected resources Real applications may need more"Sessions" are allowed in REST, subject to constraintsMulti-step workflows a classic case27 request from client to server must contain all of the informationnecessary to understand the request, and cannot take advantage ofany stored context on the server." request from client to server must contain all of the informationnecessary to understand the request, and cannot take advantage ofany stored context on the server." request from client to server must contain all of the informationnecessary to understand the request, and cannot take advantage ofany stored context on the server." request from client to server must contain all of the informationnecessary to understand the request, and cannot take advantage ofany stored context on the server." REST workflowPreferred REST approach for workflow is to accumulate state inWorkflow involves creating new resources, and mutating existing32 reference must fit within the definition of a resource." reference must fit within the definition of a resource."a hypertext reference reference must fit within the definition of a resource."a hypertext reference So, are continuations resources?As targets of hypertext reference, they qualify by definition36 So, are continuations resources?As targets of hypertext reference, they qualify by definitionQED.37 So, are continuations resources?As targets of hypertext reference, they qualify by definitionQED.OK, too cute!38 So, are continuations resources?As targets of hypertext reference, they qualify by definitionQED.OK, too cute!REST imposes other constraints.39 Why aren't continuations resources?Often ephemeral - don't survive session40 Why aren't continuations resources?Often ephemeral - don't survive session"Easy" solution - persistent continuations41 Why aren't continuations resources?Often ephemeral - don't survive session"Easy" solution - persistent continuationsBut other issues, tooE.g. continuations tend to be opaque42 Why aren't continuations resources?Often ephemeral - don't survive session"Easy" solution - persistent continuationsBut other issues, tooE.g. continuations tend to be opaqueNot a good primary resource format43 So what are they good for?Need a little leap44 So what are they good for?Need a little leapSnapshot program state prior to generation of representationAct as cache for the representation of a resourceAccessed via ordinary URICache manager uses continuation if presentOtherwise, reifies resource45 application logic Case #4: Continuations as cached representationgeneratorsSatisfies most REST constraintsConceive as:Resource statePointer to code which generates representation47 define let* (())'item-no))'description)))))))) define let (())lambda set! ))))))))))) define let (()))(())))))) Back to high-level viewWeb application as coroutinesGood model, but too simplistic in realityClients and servers don't always just wait for each otherSupport client operations while server busy51 Final example before I can RESTExample: long-running report, REST styleClient sends request to serverServer queues request, responds with resource idLater, client requests resource using idServer reifies resource, generates representation, sends to client52 uses ConcernsPersistenceScalabilityEfficiencyCache coherenceFramework can helpWorkflows have well-defined dependenciesServer complexity - slightly suspect from REST perspectiveThen again, cache management is explicit part of REST54 design trade-off. The disadvantage is that it may decrease networkperformance by increasing the repetitive data (per-interactionoverhead) sent in a series of requests, since that data cannot beleft on the server in a shared context." -- REST 5.1.3resource state - more RESTful REST or notclarify thinking about control flow, REST applications includeddetails of URIs Lessons - Language DesignFramework designers need building blocksContinuations are an important oneBeing forced to hack these things in is bad, 'mkay?Cases in point: Java, PerlFrameworks need first-class continuations (or equivalent) at someDesired qualitiesPersistableEfficientLanguages must provide these features57 be worthwhile Time to give the puns a RESTThank you!59