Project

General

Profile

libfast - FastCGI Application Server w/ Templates » History » Version 2

« Previous - Version 2/3 (diff) - Next » - Current version
Martin Willi, 01.04.2008 09:46


libfast - FastCGI Application Server w/ Templates

libfast is a small library built around libfcgi and ClearSilver. It wrapps these libraries properly and integrates session management and a MVC-like architecture. It targets embedded systems or servers where processing power and footprint is limited and should work with any FastCGI cappable webserver.

Architecture

A web application based on libfast has a global and a session context:
  • Global context
    • inter-session data
    • [browser:trunk/src/libstrongswan/database/database.h database connections]
    • ...
  • [browser:trunk/src/libfast/context.h Session context]
    • per-session data
    • [browser:trunk/src/libfast/controller.h controllers]
    • [browser:trunk/src/libfast/filter.h filters]

libfast automatically creates and manages a session for each connecting user and allocates a private session context. In that context, a defined set of controllers and filters are allocated. These instances are per session, so you might save session-specific data in them.

The session context is synchronized, only one thread enters a session. The global context is accessed by all sessions, so you'll need to write global objects thread-save.

Building a web application

Here a small example how to set up a web application:

dispatcher_t *dispatcher;
your_global_context_implementation_t *global;

global = initialize_your_global_context();

dispatcher = dispatcher_create(NULL, FALSE, 180,
   (context_constructor_t)your_session_context_create, global);
dispatcher->add_controller(dispatcher, your_controller1_create, param1);
dispatcher->add_controller(dispatcher, your_controller2_create, param2);

dispatcher->run(dispatcher, 20);
dispatcher->waitsignal(dispatcher);

dispatcher->destroy(dispatcher);
global->destroy();

Have a look at the [browser:trunk/src/manager manager] for a more complete example.