Eidolon::Application - Eidolon application base class.
Example application package (
package ExampleApp; use base qw/Eidolon::Application/; our $VERSION = "0.01"; 1;
CGI application gateway (
use lib "./lib"; use ExampleApp; my $app = ExampleApp->new; $app->start($app->TYPE_CGI); $app->handle_request;
The Eidolon::Application class is the base high-level class of a usual Eidolon application. It creates various system objects, reads application configuration and handles user requests.
Should never be used directly, subclass it from your application's main package instead.
These steps are performed while processing user request. This sequence can be redefined by the ancestor class, but in most cases you won't need to do this.
Registry is the system information structure. This step is done first, because other parts of the system depend on the registry. For more information see "Mount points" in Eidolon::Core::Registry and Eidolon::Core::Registry module documentation.
In this step application loads and instantiates the application configuration class. It contains all basic system settings. Application configuration in example application would be stored in
lib/ExampleApp/Config.pm. For more information see Eidolon::Core::Config.
FastCGI application works like a daemon - it resides in memory, accepting connections from the web server. Whence a new connection is established, the application goes to the next step.
Actually, all the work is done in this step. First of all, the application creates the Eidolon::Core::CGI object, that is used to process all incoming data. Next, application loads system drivers using the Eidolon::Core::Loader object. The list of required drivers must be specified in the application configuration (note, that you must specify a router driver, otherwise the application will not handle requests properly). Afterwards, the application transfers execution to a router driver, which tries to find the request handler and then calls it.
If an error occurs on this step, the application calls an error handler, that is specified in application configuration (or uses the default one - Eidolon::Error).
After request (or error) handling, a CGI application shuts down, but FastCGI application goes next.
When a user request is handled, our daemon-like application is ready to serve another clients without termination, so we save a bit of system resources.
Class constructor. Creates an application object.
Application initialization. Creates system registry and loads application configuration.
$type - application type (see "CONSTANTS" section below).
User request processing. This function parses and routes the request, then it transfers execution to request handler. If any exception occurs during processing, it tries to start application's error handler. If no such handler was found, application dies.
CGI application is the default type. It is suitable for low-loaded applications. When this type is used, the web server starts one interpreter instance per user request, so if you issue high CPU usage or high memory load - use the next application type.
FastCGI application type is suitable for high-loaded applications with a lot of concurrent connections. It's faster than CGI up to 2000%. This type suggests FCGI module to be installed, otherwise application won't work.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Anton Belousov, <email@example.com>
Copyright (c) 2009, Atma 7, http://www.atma7.com