Assembly line objects

From Apibot
Revision as of 20:31, 13 April 2013 by Grigor Gatchev (talk | contribs) (some more info (will continue it later))
Jump to: navigation, search

The Assembly line objects are the entities that form an assembly line.

Types

Every object belongs to one of the following types:

  • Feeders - supply data to the assembly line
  • Fetchers - fetch full wiki objects by some identificator (eg. pages by titles)
  • Filters - let through only data that matches given criteria, or reorder the data
  • Signal modifiers - modify signals and their properties in some way
  • Workers - process the data in one way or another
  • Writers - write the processed data (back to the wiki, or to a file, etc.)

For each of those types there is a subtree named after it, inside the /line subdirectory in the bot.

Line structure and creation

An assembly line typically starts with a feeder object and ends with a writer object, typically with some other objects (writers etc) in between.

Objects are strung one to another via two procedures:

  • $worker->link_to ( $feeder ); will link $worker after $feeder in the line.
  • $worker->link_with ( $writer ); will link $worker before $writer in the line.

Several objects can be linked after and / or before one object:

$filter1->link_to ( $feeder );
$filter2->link_to ( $feeder );
$filter3->link_to ( $feeder );

$worker->link_to ( $filter1 );
$worker->link_to ( $filter2 );
$worker->link_to ( $filter3 );

In this line, $worker must get from $feeder data that match any of three completely different conditions, so three different filters must be connected in parallel.

All line objects require at least one parameter - the bot $mains object - on creation. Most require and / or can take more parameters.

Creating Assembly line objects classes

The line objects are designed so as to be easily written and modified. Anyone with some PHP knowledge will be able to create new object classes, either based on existing ones, or from the ground up.

All new object classes must derive from the Line_Slot class, found in the line/_line_slot.php file. In addition, classes of a certain type should best derive from its generic class, typically found in the file _generic.php in the object type subpath in line.