summaryrefslogtreecommitdiff
path: root/lib/queuehandler.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@controlyourself.ca>2009-07-04 00:31:28 -0400
committerEvan Prodromou <evan@controlyourself.ca>2009-07-04 00:31:28 -0400
commit49c5c6f92bc1d06e6464eade81eead891d86f10d (patch)
treefb59040b322ff3170f392f9f65429c068ab5b5a6 /lib/queuehandler.php
parent741eb1a28bbe505364baa440539bbc5ed6fbe5e0 (diff)
move handling code into queuemanager
Diffstat (limited to 'lib/queuehandler.php')
-rw-r--r--lib/queuehandler.php30
1 files changed, 3 insertions, 27 deletions
diff --git a/lib/queuehandler.php b/lib/queuehandler.php
index ddb47a28e..c0f38f4e3 100644
--- a/lib/queuehandler.php
+++ b/lib/queuehandler.php
@@ -25,7 +25,7 @@ require_once(INSTALLDIR.'/classes/Notice.php');
define('CLAIM_TIMEOUT', 1200);
define('QUEUE_HANDLER_MISS_IDLE', 10);
-define('QUEUE_HANDLER_HIT_IDLE', 10);
+define('QUEUE_HANDLER_HIT_IDLE', 0);
class QueueHandler extends Daemon
{
@@ -42,7 +42,7 @@ class QueueHandler extends Daemon
function timeout()
{
- return null;
+ return 60;
}
function class_name()
@@ -96,31 +96,7 @@ class QueueHandler extends Daemon
$qm = QueueManager::get();
- while (true) {
- $this->log(LOG_DEBUG, 'Checking for notices...');
- $notice = $qm->nextItem($queue, $timeout);
- if (empty($notice)) {
- $this->log(LOG_DEBUG, 'No notices waiting; idling.');
- // Nothing in the queue. Do you
- // have other tasks, like servicing your
- // XMPP connection, to do?
- $this->idle(QUEUE_HANDLER_MISS_IDLE);
- } else {
- $this->log(LOG_INFO, 'Got notice '. $notice->id);
- // Yay! Got one!
- if ($this->handle_notice($notice)) {
- $this->log(LOG_INFO, 'Successfully handled notice '. $notice->id);
- $qm->done($notice, $queue);
- } else {
- $this->log(LOG_INFO, 'Failed to handle notice '. $notice->id);
- $qm->fail($notice, $queue);
- }
- // Chance to e.g. service your XMPP connection
- $this->log(LOG_DEBUG, 'Idling after success.');
- $this->idle(QUEUE_HANDLER_HIT_IDLE);
- }
- // XXX: when do we give up?
- }
+ $qm->service($queue, $this);
if (!$this->finish()) {
return false;