-
Notifications
You must be signed in to change notification settings - Fork 4
Plugin requirements
jasonpriem edited this page May 28, 2011
·
34 revisions
- A POST request containing, in the request header, a JSON-encoded array of artifact IDs.
- For external plugins (running on other people's servers), the mechanics of this are not our concern.
- For local plugins, though, we need to handle the REST interface. To do this, Jason is replacing the old system with this one: each plugin is an appropriately-named directory. Each directory contains index.php, which for Python plugins will contain this:
$pluginName = "plugin.py";
$idsJsonStr = escapeshellarg($_POST);
echo exec('python ' . $pluginName . ' ' . $idsJsonStr);
This is nothing more than a wrapper that calls the Python code and prints the output. The advantage to this is that plugin writers fluent in Python can control the entire behaviour of their plugins, and there is clear division of responsibility. The plugin directory is entirely self-contained and calls no other code.
- filter those IDs so that only relevant ones are sent to Source API
- chunk them together if their Source API gets down like that
- make as many calls to their Source API to get data on everything.
- do error checking on what they get back from the Source and handle things appropriately
- Plugins should use exponential backoff to handle bad responses from Source APIs. For now, the maximum wait interval should be 5 minutes or so, then an error should be thrown.
- For now, errors should be reported by returning a JSON object like this:
{"error": "<text of error message>"}
. In the future, we can use error codes. - In the future, plugins may want to cache responses
- Plugins may want to log reponses
Plugins return a flat array of events, possibly of different types. Each event is an object with these attributes (note the addition of a timestamp, so we know how fresh it is and can gather others over time):
id: <artifact id>
source_name: <source name (eg, "slideshare")>
values: an object containing results as {metric-name:metric-value}.
metrics can be strings, integers, or the special string "NA" if no value is expected.
Example: using the Slideshare plugin,
"http://www.slideshare.net/jason/jason" returns {"title": "my awesome slides", "views": 176 }
"10.5061/dryad.8384" returns {"title":"NA", "views":"NA"}
icon: <url for icon img>
type: <the type of the artifact, like "article" or "slides">
timestamp: <current UNIX timestamp in seconds>
Also, in the future, plugins respond to a special GET request with the "?register=true" flag sent, sending documentation about the plugin (I suggest this is a post-alpha project)