Made YammerImport more robust against errors; can now pause/resume/reset the import state from the admin interface.

This commit is contained in:
Brion Vibber
2010-09-28 15:45:00 -07:00
parent c62e4d0800
commit 62d9b66dff
7 changed files with 113 additions and 16 deletions

View File

@@ -38,21 +38,24 @@ class YammerQueueHandler extends QueueHandler
{
$runner = YammerRunner::init();
if ($runner->hasWork()) {
if ($runner->iterate()) {
if ($runner->hasWork()) {
// More to do? Shove us back on the queue...
$runner->startBackgroundImport();
try {
if ($runner->iterate()) {
if ($runner->hasWork()) {
// More to do? Shove us back on the queue...
$runner->startBackgroundImport();
}
}
} catch (Exception $e) {
try {
$runner->recordError($e->getMessage());
} catch (Exception $f) {
common_log(LOG_ERR, "Error while recording error in Yammer background import: " . $e->getMessage() . " " . $f->getMessage());
}
return true;
} else {
// Something failed?
// @fixme should we be trying again here, or should we give warning?
return false;
}
} else {
// We're done!
common_log(LOG_INFO, "Yammer import has no work to do at this time; discarding.");
return true;
}
return true;
}
}