Changes between Version 1 and Version 2 of soc/2007/cgi/Concepts


Ignore:
Timestamp:
May 26, 2007, 1:37:51 PM (15 years ago)
Author:
Darren Garvey
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • soc/2007/cgi/Concepts

    v1 v2  
    1 '''SessionAdapter''' - The implementation of a ```cgi::session```.
    2 Purpose:
    3 Requirements:
     1== !SessionAdapter ==
    42
    5 Since the cache could reside in process memory, shared memory, files or a database, the class should be flexible. The actual data will be held in a std::map<std::string, T>. T should theoretically be generic, so could be boost::any.
     3The implementation of a ```cgi::session```.
    64
    7 '''CommonGatewayService'''
     5'''Purpose''': Since the session cache could reside in process memory, shared memory, files or a database, the class should be flexible. The actual data will be held in a std::map<std::string, T>. T should theoretically be generic, so could be boost::any (using this results in heap allocations, which might make it a poor default?). Maybe there should be a basic_session template which can be accessed directly to say how the data is held, and ```cgi::session``` is a ```typedef``` for a std::map<std::string,std::string> container.
    86
    9 '''CommonGatewayRequest'''
     7'''Roadmap''': A shared-memory !SessionAdapter is going to be implemented over the summer (using Boost.Interprocess). The other types will be commented, although probably not tackled (note: the in-process memory adapter would be simple to implement, but it's not a priority as it not likely to be used much).
    108
    11 '''Protocol'''
    12 Purpose:
    13 Alternatives: cgi, fcgi, scgi, http, etc.
     9== !CommonGatewayService ==
     10
     11The service is the main class in the library, similar to ```asio::io_service```, and deriving from ```asio::io_service::service```.
     12
     13'''Purpose''': This is where the request queue is held, the thread pool is managed, any initialisation of the program is done and generally what library users interact with to do anything which isn't request-specific. Within the library, a request object initialises itself by calling ```basic_service<>::get_request()```, erases itself with ```basic_service<>::end(request&)``` and either interacts with the service, or the ```connection``` associated with the request.
     14
     15== !CommonGatewayRequest ==
     16
     17The data from the client is stored in the request. Keeping transport data - eg. associated connection, destination ip, source ip - separate/enclosed seems logical. These could be held in a context<> construct, as an idea (the word comes from WSGI, although it's used in a slightly different context (NPI) there.
     18
     19== !CommonGatewayResponse ==
     20
     21Simply contains headers and a response string. It is returned to the client via a call to ```response::send(request&)```.
     22
     23== Gateway ==
     24
     25The gateway is the highest-level abstraction over the library-server interface. It manages accepting and closing connections for now.
     26
     27'''Roadmap''': gateway.hpp is basically 'complete' for now. If necessary (this is a very big if), the gateway could also be required to delegate writes to a free connection (ie. if the program has a multiplexing set of connections) or to open a connection with which to write the response. At the moment, I think the request should just hold a pointer to the connection associated with it and write directly to that. Rather than having the request/response write to the gateway, the connection could try sending the response, and if for any reason it can't, then it sends the response on to the gateway for handling.
     28
     29== Connection ==
     30
     31A Connection is the interface with the server (or outside world). It can be a pipe, a socket or just a cin/cout wrapper.
     32
     33'''Provides''': read(), write(), async_read(), async_write(), maybe more (like read_some(), write_some()).
     34
     35'''Roadmap''': A TCP socket is required for FastCGI and SCGI protocols and a std::cin/cout wrapper is required for standard cgi. Pipe support will follow support for that in asio (I don't know how that's going to work ATM). File i/o support would be nice too. In other words, a stock set of requests could be taken from files and responses written to files: this would be very useful for testing purposes.
     36
     37== Protocol ==
     38
     39'''Alternatives''': cgi, fcgi, scgi, http, etc.
     40
     41'''Roadmap''': Implement everything for cgi and fcgi protocols. scgi SHOULD be implemented, just as long as it doesn't stop the project from being completed.