Requests for comment/Zero architecture

Current Architecture

 * Varnish uses a set of IP blocks to determine carrier and sets headers
 * Very inefficient - linear search through all blocks on each mobile request


 * Zero extension shows carrier-specific banner based on the header
 * Zero and mobile extensions need to be decoupled


 * Zero Configuration is done on two en:MediaWiki:... pages
 * Partners cannot make changes themselves - must go through managers and developers
 * ''Settings are hosted on English Wikipedia instead of meta
 * The process is error-prone, there is no validation of any sorts

Partner Configuration

 * Zero extension configurations will be stored as wiki pages in JSON format, one page per partner.
 * Config pages will reside on meta-wiki, in a dedicated namespace ZeroConfig:
 * ZeroConfig namespace will be writable only by people in a dedicated security group
 * Custom content-handler will validate json structure on Save, and invalidate any related caches.
 * Custom visualizer will show settings, duplicate/inefficient IP ranges, banner visualization, etc
 * As a further improvement, the config page could have a dedicated form editor to simplify changes by the partner.


 * TBD: PARTNER name might be localizable, and might be a link to custom URL
 * TBD: Allow HTML blob instead of banner+style

Zero extension

 * The extension will get the JSON blob from the meta page  with an API call, process and verify it, and cache the result in memcached (Key = 'zero-config-' + ID). The ID will be taken from the X-CS header (set by Varnish).
 * Updating a ZeroConfig page will trigger a memcached reset for that ID

Varnish

 * See related RT ticket


 * A (semi?-)automated script will iterate through all pages in ZeroConfig namespace, validate them, and extract the IP blocks.
 * A simple text file is created and uploaded to the servers
 * Varnish extension, similar to GeoIP, will load the config file and do an IP to ID lookup:
 * - fast search among IP ranges to get carrier's ID (name of the page in the ZeroConfig namespace)