summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Andrews <candrews@integralblue.com>2010-01-22 17:14:41 -0500
committerCraig Andrews <candrews@integralblue.com>2010-01-22 17:14:41 -0500
commitef7db60fed8575c381801c0b998d9ed58aab1745 (patch)
tree951ac34544643a936a3ff814d88d4600cefd9920
parentbd72e8b96e1bc360ba46a1864c6121f3b5f11235 (diff)
Revert "Allow for instances as well as class names to be passed as queue handlers and iomanagers."
Going to use brion's SpawningDaemon instead This reverts commit bd72e8b96e1bc360ba46a1864c6121f3b5f11235.
-rw-r--r--lib/iomanager.php1
-rw-r--r--lib/iomaster.php25
-rw-r--r--lib/queuemanager.php6
-rwxr-xr-xscripts/queuedaemon.php13
4 files changed, 13 insertions, 32 deletions
diff --git a/lib/iomanager.php b/lib/iomanager.php
index f9d97d6a9..ee2ff958b 100644
--- a/lib/iomanager.php
+++ b/lib/iomanager.php
@@ -31,7 +31,6 @@
abstract class IoManager
{
- const GLOBAL_SINGLE_ONLY = -1;
const SINGLE_ONLY = 0;
const INSTANCE_PER_SITE = 1;
const INSTANCE_PER_PROCESS = 2;
diff --git a/lib/iomaster.php b/lib/iomaster.php
index 979f73e75..ce77b53b2 100644
--- a/lib/iomaster.php
+++ b/lib/iomaster.php
@@ -32,7 +32,6 @@ class IoMaster
public $id;
protected $multiSite = false;
- protected $includeGlobalSingletons = true;
protected $managers = array();
protected $singletons = array();
@@ -48,9 +47,8 @@ class IoMaster
$this->monitor = new QueueMonitor();
}
- public function init($multiSite=null, $includeGlobalSingletons = true)
+ public function init($multiSite=null)
{
- $this->includeGlobalSingletons = $includeGlobalSingletons;
if ($multiSite !== null) {
$this->multiSite = $multiSite;
}
@@ -109,7 +107,7 @@ class IoMaster
*/
protected function instantiate($class)
{
- if (is_string($class) && isset($this->singletons[$class])) {
+ if (isset($this->singletons[$class])) {
// Already instantiated a multi-site-capable handler.
// Just let it know it should listen to this site too!
$this->singletons[$class]->addSite(common_config('site', 'server'));
@@ -118,34 +116,25 @@ class IoMaster
$manager = $this->getManager($class);
- $caps = $manager->multiSite();
if ($this->multiSite) {
+ $caps = $manager->multiSite();
if ($caps == IoManager::SINGLE_ONLY) {
throw new Exception("$class can't run with --all; aborting.");
}
- if ($caps == IoManager::INSTANCE_PER_PROCESS ||
- ( $this->includeGlobalSingletons && $caps == IoManager::GLOBAL_SINGLE_ONLY )) {
+ if ($caps == IoManager::INSTANCE_PER_PROCESS) {
// Save this guy for later!
// We'll only need the one to cover multiple sites.
- if (is_string($class)){
- $this->singletons[$class] = $manager;
- }
+ $this->singletons[$class] = $manager;
$manager->addSite(common_config('site', 'server'));
}
}
- if( $this->includeGlobalSingletons || $caps != IoManager::GLOBAL_SINGLE_ONLY ) {
- $this->managers[] = $manager;
- }
+ $this->managers[] = $manager;
}
protected function getManager($class)
{
- if(is_object($class)){
- return $class;
- }else{
- return call_user_func(array($class, 'get'));
- }
+ return call_user_func(array($class, 'get'));
}
/**
diff --git a/lib/queuemanager.php b/lib/queuemanager.php
index b20a93468..291174d3c 100644
--- a/lib/queuemanager.php
+++ b/lib/queuemanager.php
@@ -119,9 +119,7 @@ abstract class QueueManager extends IoManager
{
if (isset($this->handlers[$queue])) {
$class = $this->handlers[$queue];
- if(is_object($class)) {
- return $class;
- } else if (class_exists($class)) {
+ if (class_exists($class)) {
return new $class();
} else {
common_log(LOG_ERR, "Nonexistent handler class '$class' for queue '$queue'");
@@ -184,7 +182,7 @@ abstract class QueueManager extends IoManager
* Only registered transports will be reliably picked up!
*
* @param string $transport
- * @param string $class class name or object instance
+ * @param string $class
*/
public function connect($transport, $class)
{
diff --git a/scripts/queuedaemon.php b/scripts/queuedaemon.php
index 6cce4eaa7..162f617e0 100755
--- a/scripts/queuedaemon.php
+++ b/scripts/queuedaemon.php
@@ -122,7 +122,7 @@ class QueueDaemon extends Daemon
if ($this->threads > 1) {
return $this->runThreads();
} else {
- return $this->runLoop(true);
+ return $this->runLoop();
}
}
@@ -176,8 +176,7 @@ class QueueDaemon extends Daemon
{
$this->set_id($this->get_id() . "." . $thread);
$this->resetDb();
- //only include global singletons on the first thread
- $this->runLoop($thread == 1);
+ $this->runLoop();
}
/**
@@ -214,18 +213,14 @@ class QueueDaemon extends Daemon
*
* Most of the time this won't need to be overridden in a subclass.
*
- * @param boolean $includeGlobalSingletons Include IoManagers that are
- * global singletons (should only be one instance - regardless of how
- * many processes or sites there are)
- *
* @return boolean true on success, false on failure
*/
- function runLoop($includeGlobalSingletons)
+ function runLoop()
{
$this->log(LOG_INFO, 'checking for queued notices');
$master = new IoMaster($this->get_id());
- $master->init($this->all, $includeGlobalSingletons);
+ $master->init($this->all);
$master->service();
$this->log(LOG_INFO, 'finished servicing the queue');