[CalendarServer-changes] [9684] CalendarServer/branches/users/glyph/q
source_changes at macosforge.org
source_changes at macosforge.org
Sat Aug 11 01:55:52 PDT 2012
Revision: 9684
http://trac.macosforge.org/projects/calendarserver/changeset/9684
Author: glyph at apple.com
Date: 2012-08-11 01:55:52 -0700 (Sat, 11 Aug 2012)
Log Message:
-----------
add an interface to unify enqueueWork
Modified Paths:
--------------
CalendarServer/branches/users/glyph/q/twext/enterprise/ienterprise.py
CalendarServer/branches/users/glyph/q/twext/enterprise/queue.py
Property Changed:
----------------
CalendarServer/branches/users/glyph/q/
Modified: CalendarServer/branches/users/glyph/q/twext/enterprise/ienterprise.py
===================================================================
--- CalendarServer/branches/users/glyph/q/twext/enterprise/ienterprise.py 2012-08-11 08:55:51 UTC (rev 9683)
+++ CalendarServer/branches/users/glyph/q/twext/enterprise/ienterprise.py 2012-08-11 08:55:52 UTC (rev 9684)
@@ -20,6 +20,16 @@
__all__ = [
"IAsyncTransaction",
+ "ISQLExecutor",
+ "ICommandBlock",
+ "IQueuer",
+ "IDerivedParameter",
+ "AlreadyFinishedError",
+ "ConnectionError",
+ "POSTGRES_DIALECT",
+ "SQLITE_DIALECT",
+ "ORACLE_DIALECT",
+ "ORACLE_TABLE_NAME_MAX",
]
from zope.interface import Interface, Attribute
@@ -242,3 +252,32 @@
@return: C{None}
"""
+
+
+
+class IQueuer(Interface):
+ """
+ An L{IQueuer} can enqueue work for later execution.
+ """
+
+ def enqueueWork(self, transaction, workItemType, **kw):
+ """
+ Perform some work, eventually.
+
+ @param transaction: an L{IAsyncTransaction} within which to I{commit}
+ to doing the work. Note that this work will likely be done later
+ (but depending on various factors, may actually be done within this
+ transaction as well).
+
+ @param workItemType: the type of work item to create.
+ @type workItemType: L{type}, specifically, a subtype of L{WorkItem
+ <twext.enterprise.queue.WorkItem>}
+
+ @param kw: The keyword parameters are relayed to C{workItemType.create}
+ to create an appropriately initialized item.
+
+ @return: a work proposal that allows tracking of the various phases of
+ completion of the work item.
+ @rtype: L{twext.enterprise.queue.WorkItem}
+ """
+
Modified: CalendarServer/branches/users/glyph/q/twext/enterprise/queue.py
===================================================================
--- CalendarServer/branches/users/glyph/q/twext/enterprise/queue.py 2012-08-11 08:55:51 UTC (rev 9683)
+++ CalendarServer/branches/users/glyph/q/twext/enterprise/queue.py 2012-08-11 08:55:52 UTC (rev 9684)
@@ -73,8 +73,9 @@
# Note, txn was started before, will be committed later...
for customerID in (yield Select([schema.CUSTOMER.CUSTOMER_ID],
From=schema.CUSTOMER).on(txn)):
- # peerPool is a PeerConnectionPool
- peerPool.enqueueWork(txn, CouponWork, customerID=customerID)
+ # queuer is a provider of IQueuer, of which there are several
+ # implementations in this module.
+ queuer.enqueueWork(txn, CouponWork, customerID=customerID)
"""
from socket import getfqdn
@@ -82,6 +83,8 @@
from os import getpid
from datetime import datetime
+from zope.interface import implements
+
from twisted.application.service import Service
from twisted.internet.protocol import Factory
from twisted.internet.defer import (
@@ -101,6 +104,7 @@
from twext.enterprise.dal.model import Table, Schema, SQLType, Constraint
from twisted.internet.endpoints import TCP4ServerEndpoint
from twext.enterprise.dal.syntax import Lock
+from twext.enterprise.ienterprise import IQueuer
def makeNodeSchema(inSchema):
"""
@@ -594,6 +598,7 @@
controller to do work. It is the opposite end of the connection from
L{ConnectionFromWorker}.
"""
+ implements(IQueuer)
def __init__(self, transactionFactory, schema, whenConnected,
boxReceiver=None, locator=None):
@@ -859,6 +864,7 @@
@ivar peers: The list of currently connected peers.
@type peers: L{list} of L{PeerConnectionPool}
"""
+ implements(IQueuer)
getfqdn = staticmethod(getfqdn)
getpid = staticmethod(getpid)
@@ -1180,6 +1186,7 @@
within the same transaction. While this is technically correct, it is not
very efficient.
"""
+ implements(IQueuer)
def enqueueWork(self, txn, workItemType, **kw):
"""
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120811/d528c388/attachment-0001.html>
More information about the calendarserver-changes
mailing list