Riskle Server Brainstorm

Component Requirements

  • This component will accept multiple incoming socket connections
  • This component will be able to limit the maximum number of connections it accepts
  • This component will be able to report a status of all currently active connections
  • This component will be able to fork worker processes in the background
  • This component will allow for easy forked job management
  • This component will be able to speak any tcp protocol as long as you have an adapter for it

Sub-components

The “core” server Riskle_Server should be kept as simple as possible. Thus the below-mentionned protocol would not be part of it. Instead, it’ll just instantiate workers as defined at startup (see use cases).

The protocol would be implemented into a sub package called Riskle_Server_Dynamic (name tbd), allowing the client to ask for a specific worker to be used for the job.

There could be another built-in server engine, Riskle_Server_Http, able to parse http requests and forward them through a Zend_Controller_Request_Http.

Jobs Management

The “core” server should provide an API to manage forked worker. Following operations should be available:

  • count currently active workers
  • kill a specific worker / all workers of a specific type / all workers
  • send signals to a specific worker / all workers of a certain type / all workers

It will be up to the adapters to decide how the operations will be made available to clients.

Class Reference

  • Riskle_Tcp_Server (abreviated to RTS_)
  • RTS_Adapter_Interface
  • RTS_Adapter_Abstract
  • RTS_Adapter_Standard
  • RTS_Adapter_Dynamic
  • RTS_Adapter_Http
  • RTS_Worker_Interface
  • RTS_Worker_Abstract

Use Cases

// dynamic server adapter asks client which worker they want to be used
$server = Riskle_Tcp_Server::factory('Dynamic', array(
    'address' => '127.0.0.1',
    'port' => 9000,
));
$server->listen();
$server = Riskle_Tcp_Server::factory('Http', array(
    'address' => '0.0.0.0',
    'port' => 8080,
    'documentRoot' =>'/var/www',
));
$server->listen();