[CalendarServer-changes] [9673] CalendarServer/branches/users/glyph/q

source_changes at macosforge.org source_changes at macosforge.org
Sat Aug 11 01:55:43 PDT 2012


Revision: 9673
          http://trac.macosforge.org/projects/calendarserver/changeset/9673
Author:   glyph at apple.com
Date:     2012-08-11 01:55:42 -0700 (Sat, 11 Aug 2012)
Log Message:
-----------
Add .enqueue() method for application use.

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/q/txdav/common/datastore/sql.py

Property Changed:
----------------
    CalendarServer/branches/users/glyph/q/

Modified: CalendarServer/branches/users/glyph/q/txdav/common/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/glyph/q/txdav/common/datastore/sql.py	2012-08-11 08:55:41 UTC (rev 9672)
+++ CalendarServer/branches/users/glyph/q/txdav/common/datastore/sql.py	2012-08-11 08:55:42 UTC (rev 9673)
@@ -85,6 +85,7 @@
 from txdav.xml.rfc2518 import DisplayName
 
 from txdav.base.datastore.util import normalizeUUIDOrNot
+from twext.enterprise.queue import NullQueuer
 
 from pycalendar.datetime import PyCalendarDateTime
 
@@ -132,8 +133,13 @@
 
     @ivar quota: the amount of space granted to each calendar home (in bytes)
         for storing attachments, or C{None} if quota should not be enforced.
+    @type quota: C{int} or C{NoneType}
 
-    @type quota: C{int} or C{NoneType}
+    @ivar queuer: An object with an C{enqueueWork} method, from
+        L{twext.enterprise.queue}.  Initially, this is a L{NullQueuer}, so it
+        is always usable, but in a properly configured environment it will be
+        upgraded to a more capable object that can distribute work throughout a
+        cluster.
     """
 
     implements(ICalendarStore)
@@ -160,6 +166,7 @@
         self.logSQL = logSQL
         self.logTransactionWaits = logTransactionWaits
         self.timeoutTransactions = timeoutTransactions
+        self.queuer = NullQueuer()
         self._migrating = False
         self._enableNotifications = True
 
@@ -335,6 +342,8 @@
         if self.timeoutSeconds:
             self.delayedTimeout = self.callLater(self.timeoutSeconds, _forceAbort)
 
+
+
 class CommonStoreTransaction(object):
     """
     Transaction implementation for SQL database.
@@ -380,7 +389,10 @@
         self.paramstyle = sqlTxn.paramstyle
         self.dialect = sqlTxn.dialect
 
-        self._stats = TransactionStatsCollector(self._label, self._store.logStatsLogFile) if self._store.logStats else None
+        self._stats = (
+            TransactionStatsCollector(self._label, self._store.logStatsLogFile)
+            if self._store.logStats else None
+        )
         self.statementCount = 0
         self.iudCount = 0
         self.currentStatement = None
@@ -400,6 +412,22 @@
             __import__("txdav.carddav.datastore.sql")
 
 
+    def enqueue(self, workItem, **kw):
+        """
+        Enqueue a L{twext.enterprise.queue.WorkItem} for later execution.
+
+        For example::
+
+            yield (txn.enqueue(MyWorkItem, workDescription="some work to do")
+                   .whenProposed())
+
+        @return: a work proposal describing various events in the work's
+            life-cycle.
+        @rtype: L{twext.enterprise.queue.WorkProposal}
+        """
+        return self._store.queuer.enqueueWork(self, workItem, **kw)
+
+
     def store(self):
         return self._store
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120811/2a9a2194/attachment-0001.html>


More information about the calendarserver-changes mailing list