|
NAMESquatting::On::Continuity - use Continuity as the server for your Squatting appSYNOPSISRunning a Squatting application on top of Continuity:use App 'On::Continuity'; App->init; App->continue(port => 2012); DESCRIPTIONThe purpose of this module is to add a "continue" method to your app that will start a Continuity-based web server when invoked. To use this module, pass the string 'On::Continuity' to the "use" statement that loads your Squatting app.APIContinuity meets MVC (or just VC, actually)App->continue(%options)This method starts a Continuity-based web server. The %options are passed straight through to Continuity, and they let you specify things like what port to run the server on. EXPLANATIONThe Special Powers of ContinuityContinuity has 2 highly unusual (but useful) capabilities.
The easiest way to explain this is by example. Becoming RESTlessConsider this controller which has an infinite loop in it.C( Count => [ '/@count' ], get => sub { my ($self) = @_; my $cr = $self->cr; my $i = 1; while (1) { $cr->print($i++); $cr->next; } }, continuity => 1, ) Here, the code is dropping down to the Continuity level. The $cr variable contains a Continuity::Request object, and with that in hand, we can try something as audacious as an infinite loop. However, this while loop does not spin out of control and eat up all your CPU. The "$cr->next" statement will pause execution of the current coroutine, and it will wait until the next HTTP request to come in. Thus, you can hit reload multiple times and watch $i increment each time. However, not just any HTTP request will wake this coroutine up. To make "$cr->next" stop blocking, a request with the following properties will have to come in.
The key is this line: queue => { get => 'name_of_queue' } When you're squatting on Continuity, you're allowed to define your controllers with a "queue" attribute. It should contain a hashref where the keys are HTTP methods (in lower case) and the values are unique strings that will be used internally by Continuity to differentiate one queue of requests from another. Every method mentioned in "queue" will be given its own coroutine to run in. Pausing for Other EventsTO BE CONTINUED...For a sneak peak, take a look at the Chat application in the eg/ directory. SEE ALSOCoro, Continuity, Continuity::Mapper, Squatting::Mapper
Visit the GSP FreeBSD Man Page Interface. |