NAME
Continuity::Mapper - Map a request onto a session
DESCRIPTION
This is the session dictionary and mapper. Given an HTTP request, mapper gives said request to the correct session. Mapper makes sessions as needed and stores them. Mapper 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
$mapper = Continuity::Mapper->new( callback => sub { ... } )
Create a new session mapper.
Contuinity::Server does the following by default:
$server = Continuity::Server->new(
adapter => Continuity::Adapter::HttpDaemon->new,
mapper => Continuity::Mapper->new( callback => \::main )
);
If you subclass this, you'll need to explicitly pass an instance of your mapper during server creation (including the callback).
$session_id = $mapper->get_session_id_from_hit($request)
Uses the defined strategies (ip, path, cookie) to create a session identifier for the given request. This is what you'll most likely want to override, if anything.
$request is generally an HTTP::Request, though technically may only have a subset of the functionality.
$mapper->map($request)
Send the given request to the correct session, creating it if necessary.
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->{sessions}->{$session_id}
, which holds a queue of pending requests for the session to process.
So actually map()
just drops the request into the correct session queue.
$request_queue = $mapper->new_request_queue($session_id)
Returns a brand new session request queue, and starts a session to pull requests out the other side.
$mapper->enqueue($request, $request_queue)
Add the given request to the given request queue.
This is a good spot to override for some tricky behaviour... mostly for pre-processing requests before they get to the session handler. This particular implementation will optionally print the HTTP headers for you.
SEE ALSO
AUTHOR
Brock Wilcox <awwaiid@thelackthereof.org>
http://thelackthereof.org/
COPYRIGHT
Copyright (c) 2004-2007 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.