NAME

Continuity::Mapper - Map a request onto a continuation

DESCRIPTION

This is the continuation dictionary and mapper. Given an HTTP::Request it returns a continuation. It makes continuations as needed, stores them, and, when a session already exists, returns the appropriate continuation. This class may be subclassed to implement other strategies for associating requests with continuations. The default strategy is (in limbo but quite possibily) based on client IP address plus URL.

METHODS

new()

Create a new continuation mapper.

$mapper = Continuity::Mapper->new( callback => sub { } )

Contuinity::Server does the following by default:

Continuity::Server->( 
  mapper   => Continuity::Mapper->new(), 
  adapter  => Continuity::Adapter::HttpDaemon->new(), 
  callback => sub { },
)

The mapper => $ob argument pair should be passed to Continuity::Server if an an instance of a different implementation is desired.

map()

Accepts an HTTP::Request object and returns an existing or new coroutine as appropriate.

$mapper->map($request)

This implementation uses the get_session_id_from_hit() method of this same class to get an identifying string from information in the request object. This is used as an index into $self->{continuations}->{$session_id}, which holds a code ref (probably a coroutine code ref) if one exists already. This implementation wraps the main::main() method in a csub { } to create a new coroutine, which is done as necessary.

new_continuation()

Returns a special coroutine reference.

$mapper->new_continuation()

csub { } from Coro::Cont creates these. Aside from keeping execution context which can be yielded from and then later resumed, they act like normal subroutine references. This default implementation creates them from the main:: routine of the program.

$mapper->exec_cont($subref, $request) (XXX wrong)

Override in subclasses for more specific behavior. This default implementation sends HTTP headers, selects $conn as the default filehandle for output, and invokes $subref (which is presumabily a continuation) with $request and $conn as arguments.

SEE ALSO

Continuity
Coro
Coro::Cont

AUTHOR

Brock Wilcox <awwaiid@thelackthereof.org>
http://thelackthereof.org/

COPYRIGHT

Copyright (c) 2004-2006 Brock Wilcox <awwaiid@thelackthereof.org>. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.