GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Squatting::On::Continuity(3) User Contributed Perl Documentation Squatting::On::Continuity(3)

Squatting::On::Continuity - use Continuity as the server for your Squatting app

Running a Squatting application on top of Continuity:

  use App 'On::Continuity';
  App->init;
  App->continue(port => 2012);

The 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.

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.

Continuity has 2 highly unusual (but useful) capabilities.
1. It can hold many simultaneous HTTP connections open.
2. It can "pause" execution until the next request comes in.

The easiest way to explain this is by example.

Consider 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.

It has to have the same session_id.
It has to be for the same controller.
It has to be a GET request.

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.

TO BE CONTINUED...

For a sneak peak, take a look at the Chat application in the eg/ directory.

Coro, Continuity, Continuity::Mapper, Squatting::Mapper
2013-01-23 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.