Taxi::Mysql::Server - extendable full-text index using mysql: server daemon


NAME

Taxi::Mysql::Server - extendable full-text index using mysql: server daemon

(Back to Top)


PACKAGES

Taxi::Mysql::Server
Taxi::Mysql::Server::URI
Taxi::Mysql::Server::URI::response
Taxi::Mysql::Server::URI::file
Taxi::Mysql::Server::URI::directory
Taxi::Mysql::Server::URI::query

(Back to Top)


SYNOPSIS

 ##========================================================================
 ## PRELIMINARIES
 use Taxi::Mysql::Server;

Taxi::Mysql::Server Synopsis

 ##========================================================================
 ## Constructors etc.
 $srv = $CLASS_OR_OBJ->new(%args);
 ##========================================================================
 ## API: signal handlers
 $reaper_sub = $srv->_reaper();
 $catcherSub = $srv->_catcher();
 ##========================================================================
 ## API: prepare underlying objects
 $undef = $srv->propagateLogger($obj);
 $srv   = $srv->prepare();
 ##========================================================================
 ## API: access control
 $csock = $srv->clientSocket($clientRequestOrSocket);
 $bool  = $srv->clientAllowed($clientSock);
 $undef = $srv->denyClient($clientSock);
 ##========================================================================
 ## API: error handling
 $undef = $srv->clientError($clientSock,$statusCode,@message);
 ##========================================================================
 ## API: run server
 $rc = $srv->run();
 $rc = $srv->runSerial();
 $rc = $srv->runForked();
 ##========================================================================
 ## API: client request
 ($uri,$localPath) = $srv->getURI($uri_string);
 \%clientRequestParams_or_undef = $srv->parseClientRequest($csock);
 $rc = $srv->serveClientRequest(\%clientRequestParams_or_undef);
 ##========================================================================
 ## I/O: Hooks
 $tmpData = $obj->preSaveHook();
 $undef   = $obj->postSaveHook($tmpData);
 ##========================================================================
 ## URI configs: general
 $uri            = $class_or_obj->new(%options);
 $shortname      = $uri->shortname();
 $bool           = $uri->prepare($server);
 \%clientRequest = $uri->parseClientRequest($server, $localPath, $clientSocket, $clientHttpRequest);
 $rc             = $uri->processClientRequest($server, \%clientRequest);

Taxi::Mysql::Server::URI Synopsis

 ##========================================================================
 ## URI configs: General
 $uri = $class_or_obj->new(%options);

Taxi::Mysql::Server::URI::response Synopsis

 ##========================================================================
 ## URI configs: static responses
 $uri = $class_or_obj->new(%options);
 $bool = $obj->prepare($srv);

Taxi::Mysql::Server::URI::file Synopsis

 ##========================================================================
 ## URI configs: static files
 $uri  = $class_or_obj->new(%options);
 $bool = $uri->prepare($server);
 $rc   = $uri->processClientRequest($server, $clientRequest);

Taxi::Mysql::Server::URI::directory Synopsis

 ##========================================================================
 ## URI configs: static directories
 $uri  = $class_or_obj->new(%options);
 $bool = $uri->prepare($server);
 \%clientRequest = $uri->parseClientRequest($server, $localPath, $clientSocket, $clientHttpRequest);
 $rc = $uri->processClientRequest($server, $clientRequest);

Taxi::Mysql::Server::URI::query Synopsis

 ##========================================================================
 ## URI configs: index queries
 $uri  = $class_or_obj->new(%options);
 $bool = $uri->prepare($server);
 \%clientRequest = $uri->parseClientRequest($server, $localPath, $clientSocket, $clientHttpRequest);
 $rc = $uri->processClientRequest($server, $clientRequest);

(Back to Top)


DESCRIPTION

Taxi::Mysql::Server implements a standalone HTTP server for parsing user queries passed in as CGI parameters via HTTP requests, formatting them according to user specifications, and passing the formatted results back to the remote client.

The Taxi::Mysql::Server::URI classes implement processing routines for various kinds of data which may be requested by a client. By far the most interesting (and the most complex) of these is the Taxi::Mysql::Server::URI::query class.

Taxi::Mysql::Server Description

Globals etc.

Variable: @ISA

Taxi::Mysql::Server inherits from Taxi::Mysql::Base.

Constructors etc.

new
 $srv = $CLASS_OR_OBJ->new(%args);

Object structure / known %args:

 ##-- Basic options
 #index      => $index,      ##-- underlying index
 fmtClass    => $class,      ##-- query hit formatter class (default: see $ix->newFormat())
 fmtArgs     => \%fmtArgs,   ##-- underlying hit formatter args (default: see $ix->newFormat())
 parserClass => $class,      ##-- query parser class
 parserArgs  => \%prsrArgs,  ##-- underlying query parser args (default: index only)
 ##-- Daemon options
 daemonArgs => \%daemonArgs, ##-- args to HTTP::Daemon->new()
 daemonMode => $daemonMode,  ##-- one of 'fork', 'serial' [default='serial']
 uris       => \%uri2config, ##-- maps local URI paths to configs (see below)
 ##-- Access control options: ($allowed || !$denied)
 allow => \@allow_ip_regexes, ##-- allow queries from these clients (default=none)
 deny  => \@deny_ip_regexes,  ##-- deny queries from these clients (default=none)
 _allow => $allow_ip_regex,   ##-- single allow regex (compiled by 'prepare()')
 _deny  => $deny_ip_regex,    ##-- single deny regex (compiled by 'prepare()')
 ##-- Logging options
 logger      => $logger,     ##-- a Taxi::Mysql::Logger object
 verbose     => $verbose,    ##-- verbosity level
 ##-- Low-level data
 daemon => $http_daemon,    ##-- underlying HTTP daemon

URI config values as specified in 'uris' may be specified as:

Common URI subclasses and their arguments:

API: signal handlers

_reaper
 $reaper_sub = $srv->_reaper();

Zombie killer for forking server.

_catcher
 $catcherSub = $srv->_catcher();

POSIX signal handler. Default implementation shuts down after catching any signal.

API: prepare underlying objects

propagateLogger
 undef = $srv->propagateLogger($obj);
 undef = $srv->propagateLogger($obj, $logClass)

Annoying hack to propagate the server object's logging facility to another object $obj. Called e.g. for $srv->{index}.

This is very ugly and should be replaced with something more sensible.

prepare
 $srv = $srv->prepare();

Prepares server to run, compiling URI objects as needed from user specifications.

API: access control

clientSocket
 $csock = $srv->clientSocket($clientRequestOrSocket);

Return the actual socket (IO::Socket::INET or subclass) associated with $clientRequestOrSocket, which itself may be either a socket or a client request HASH-ref.

clientAllowed
 $bool = $srv->clientAllowed($clientSock);

Returns true iff $cli is allowed to access the server.

denyClient
 undef = $srv->denyClient($clientSock);
 undef = $srv->denyClient($clientSock, $denyMessage)

Kicks $clientSock off the server, with denial message $denyMessage. Shuts down the client socket.

API: error handling

clientError
 undef = $srv->clientError($clientSock,$statusCode,@message);

Sends an error message to the client and shuts down the client socket. $statusCode is an HTTP status code, e.g. HTTP::Status::RC_FORBIDDEN().

API: run server

run
 $rc = $srv->run()

Runs the server daemon in the selected operation mode (serial or fork) until a fatal error occurs.

See also: nohup(1), kill(1).

runSerial
 $rc = $srv->runSerial();

Guts for the serial server; called by run() in serial mode.

runForked
 $rc = $srv->runForked();

Guts for the forking server; called by run() in forking mode.

API: client request

getURI
 ($uri,$localPath) = $srv->getURI($uri_string);

Gets the URI object associated with the client request $uri_string, or undef if no URI matched.

parseClientRequest
 \%clientRequestParams_or_undef = $srv->parseClientRequest($csock);
 \%clientRequestParams_or_undef = $srv->parseClientRequest($csock,$httpRequest)

Common code for client request parsing, returns a client request HASH-ref on success, undef if parsing the client request failed. Note that this code always runs in top-level server process (even for the forking mode server), due chiefly to threading problems with Parse::Lex.

serveClientRequest
 $rc = $srv->serveClientRequest(\%clientRequestParams_or_undef);

Service the client request \%clientRequestParams_or_undef via the URI associated with it. This code is run in a separate process for the forking server.

I/O: Hooks

preSaveHook
 $tmpData = $obj->preSaveHook();
postSaveHook
 undef = $obj->postSaveHook($tmpData);

Taxi::Mysql::Server::URI Description

new
 $uri = $class_or_obj->new(%options);

New URI.

shortname
 $shortname = $uri->shortname();

Short URI name, for log messages.

prepare
 $bool = $uri->prepare($server);

Prepare the URI for running under $server.

parseClientRequest
 \%clientRequest = $uri->parseClientRequest($server, $localPath, $clientSocket, $clientHttpRequest);

Perform any parsing necessary on the client request.

processClientRequest
 $rc = $uri->processClientRequest($server, $clientRequest);

Process the client request, sending data back to the client as required.

Taxi::Mysql::Server::URI::response Description

For URIs using static cached HTTP::Response objects.

Variable: @ISA

Inherits from Taxi::Mysql::Server::URI.

new
 $uri = $class_or_obj->new(%options);

%options:

 response => $response ##-- HTTP::Response to serve to clients
processClientRequest

(undocumented)

Taxi::Mysql::Server::URI::file Description

URI subclass for serving static files.

Variable: @ISA

Inherits from Taxi::Mysql::Server::URI.

new
 $uri = $class_or_obj->new(%options);

%options:

 file => $filename  ##-- filename to serve to clients
prepare
 $bool = $obj->prepare($srv);
processClientRequest

Taxi::Mysql::Server::URI::dir Description

URI subclass for serving any file recursively under some directory.

Variable: @ISA

Inherits from Taxi::Mysql::Server::URI.

new
 $uri = $class_or_obj->new(%options);

%options:

 dir => $directory ##-- directory to serve (default='.')
prepare
 $bool = $uri->prepare($server);
processClientRequest
 $rc = $uri->processClientRequest($server, $clientRequest);

Taxi::Mysql::Server::URI::query Description

URI subclass for processing client index queries.

Variable: @ISA

Inherits from Taxi::Mysql::Server::URI.

new
 $uri = $class_or_obj->new(%options);

%options:

 encoding=>'UTF-8', ##-- default query encoding
 index=>undef,      ##-- underlying index [REQUIRED]
 format=>undef,     ##-- deault hit format [REQUIRED(?)]
prepare
 $bool = $uri->prepare($server);
parseClientRequest
 \%clientRequest = $uri->parseClientRequest($server, $localPath, $clientSocket, $clientHttpRequest);
processClientRequest
 $rc = $uri->processClientRequest($server, $clientRequest);

(Back to Top)


ACKNOWLEDGEMENTS

Perl by Larry Wall.

(Back to Top)


AUTHOR

Bryan Jurish <moocow@ling.uni-potsdam.de>

(Back to Top)


COPYRIGHT AND LICENSE

Copyright (C) 2006 by Bryan Jurish

This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.7 or, at your option, any later version of Perl 5 you may have available.

(Back to Top)


SEE ALSO

perl(1), taxi-query.perl(1), taxi-server.perl(1), Taxi::Mysql(3perl), Taxi::Mysql::Query::Parser(3perl), Taxi::Mysql::Query::Format(3perl).

(Back to Top)

 Taxi::Mysql::Server - extendable full-text index using mysql: server daemon