summaryrefslogtreecommitdiff
path: root/lib/stompqueuemanager.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2010-01-16 07:48:59 -0800
committerEvan Prodromou <evan@status.net>2010-01-16 07:48:59 -0800
commit21c3e08804b312aaea21ae6bd0a0691304d6e4cd (patch)
tree9a950feabe17cd52e241eddf06d61409a190bba6 /lib/stompqueuemanager.php
parentd6b8b13116b9a2de5d745487277551b281796975 (diff)
parent598072468c9fdb07df2cda9da207f123b14566ae (diff)
Merge branch 'master' of git@gitorious.org:statusnet/mainline
Diffstat (limited to 'lib/stompqueuemanager.php')
-rw-r--r--lib/stompqueuemanager.php52
1 files changed, 52 insertions, 0 deletions
diff --git a/lib/stompqueuemanager.php b/lib/stompqueuemanager.php
index 3090e0bfb..00590fdb6 100644
--- a/lib/stompqueuemanager.php
+++ b/lib/stompqueuemanager.php
@@ -66,10 +66,62 @@ class StompQueueManager extends QueueManager
*
* @fixme possibly actually do subscription here to save another
* loop over all sites later?
+ * @fixme possibly don't assume it's the current site
*/
public function addSite($server)
{
$this->sites[] = $server;
+ $this->initialize();
+ }
+
+
+ /**
+ * Instantiate the appropriate QueueHandler class for the given queue.
+ *
+ * @param string $queue
+ * @return mixed QueueHandler or null
+ */
+ function getHandler($queue)
+ {
+ $handlers = $this->handlers[common_config('site', 'server')];
+ if (isset($handlers[$queue])) {
+ $class = $handlers[$queue];
+ if (class_exists($class)) {
+ return new $class();
+ } else {
+ common_log(LOG_ERR, "Nonexistent handler class '$class' for queue '$queue'");
+ }
+ } else {
+ common_log(LOG_ERR, "Requested handler for unkown queue '$queue'");
+ }
+ return null;
+ }
+
+ /**
+ * Get a list of all registered queue transport names.
+ *
+ * @return array of strings
+ */
+ function getQueues()
+ {
+ $site = common_config('site', 'server');
+ if (empty($this->handlers[$site])) {
+ return array();
+ } else {
+ return array_keys($this->handlers[$site]);
+ }
+ }
+
+ /**
+ * Register a queue transport name and handler class for your plugin.
+ * Only registered transports will be reliably picked up!
+ *
+ * @param string $transport
+ * @param string $class
+ */
+ public function connect($transport, $class)
+ {
+ $this->handlers[common_config('site', 'server')][$transport] = $class;
}
/**