0013340: pass actionqueue config to queue backend
authorPhilipp Schüle <p.schuele@metaways.de>
Sun, 16 Jul 2017 16:04:21 +0000 (18:04 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Sun, 16 Jul 2017 17:17:03 +0000 (19:17 +0200)
* and adds some debug logging to redis backend

https://forge.tine20.org/view.php?id=13340

Change-Id: I5e5c6d54317be3aaac2e2b3763ff35a96837bffc
Reviewed-on: http://gerrit.tine20.com/customers/5203
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Tinebase/ActionQueue/Backend/Redis.php
tine20/Tinebase/Config.php

index 8d12441..ebd9196 100644 (file)
@@ -76,7 +76,9 @@ class Tinebase_ActionQueue_Backend_Redis implements Tinebase_ActionQueue_Backend
         $this->_queueStructName  = $this->_options['queueName'] . $this->_options['redisQueueSuffix'];
         $this->_dataStructName   = $this->_options['queueName'] . $this->_options['redisDataSuffix'];
         $this->_daemonStructName = $this->_options['queueName'] . $this->_options['redisDaemonSuffix'] . $this->_options['redisDaemonNumber'];
-        
+
+        // Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' options: ' . print_r($this->_options, true));
+
         $this->connect();
     }
 
@@ -100,6 +102,8 @@ class Tinebase_ActionQueue_Backend_Redis implements Tinebase_ActionQueue_Backend
         
         $this->_redis = new Redis;
         if (! $this->_redis->connect($host, $port, $timeout)) {
+            Tinebase_Core::getLogger()->err(__METHOD__ . '::' . __LINE__ . ' Could not connect to redis server at ' . $host);
+            Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' options: ' . print_r($this->_options, true));
             throw new Tinebase_Exception_Backend('Could not connect to redis server at ' . $host);
         }
     }
@@ -208,6 +212,11 @@ class Tinebase_ActionQueue_Backend_Redis implements Tinebase_ActionQueue_Backend
             ->lPush($this->_queueStructName, $jobId)
             ->exec();
 
+        Tinebase_Core::getLogger()->debug(
+            __METHOD__ . '::' . __LINE__ . " queued job " . $jobId . " on queue " . $this->_queueStructName
+            . " (datastructname: " . $this->_dataStructName . ")"
+        );
+
         return $jobId;
     }
     
index d5c8c9e..57ec9ad 100644 (file)
@@ -534,6 +534,9 @@ class Tinebase_Config extends Tinebase_Config_Abstract
     const ACTIONQUEUE = 'actionqueue';
     const ACTIONQUEUE_BACKEND = 'backend';
     const ACTIONQUEUE_ACTIVE = 'active';
+    const ACTIONQUEUE_HOST = 'host';
+    const ACTIONQUEUE_PORT = 'port';
+    const ACTIONQUEUE_NAME = 'queueName';
 
     const QUOTA = 'quota';
     const QUOTA_INCLUDE_REVISION = 'includeRevision';
@@ -809,6 +812,18 @@ class Tinebase_Config extends Tinebase_Config_Abstract
                     'type'                              => Tinebase_Config::TYPE_BOOL,
                     'default'                           => false
                 ),
+                self::ACTIONQUEUE_HOST       => array(
+                    'type'                              => Tinebase_Config::TYPE_STRING,
+                    'default'                           => 'localhost'
+                ),
+                self::ACTIONQUEUE_PORT       => array(
+                    'type'                              => Tinebase_Config::TYPE_INT,
+                    'default'                           => 6379
+                ),
+                self::ACTIONQUEUE_NAME       => array(
+                    'type'                              => Tinebase_Config::TYPE_STRING,
+                    'default'                           => 'TinebaseQueue'
+                ),
             ),
             'default'                           => array()
         ),