Commit caf745f6 authored by Jim Fulton's avatar Jim Fulton Committed by GitHub

Merge pull request #76 from zopefoundation/IMultiCommitStorage

Define a new interface for storages that support the new commit protocol.
parents c5fe46d0 d74589ef
......@@ -776,12 +776,8 @@ class IStorage(Interface):
called while the storage transaction lock is held. It takes
the new transaction id generated by the transaction.
The return value must be the committed tid. It is used to set the
serial for objects whose ids were passed to previous store calls
in the same transaction.
For compatibility, the return value can also be None, in which case
store/tpc_vote must return the serial of stored objects.
The return value may be None or the transaction id of the
committed transaction, as described in IMultiCommitStorage.
"""
def tpc_vote(transaction):
......@@ -797,20 +793,50 @@ class IStorage(Interface):
without an error, then there must not be an error if
tpc_finish or tpc_abort is called subsequently.
The return value can be either None or a sequence of oids for which
a conflict was resolved.
For compatibility, the return value can also be a sequence of object-id
The return value can be None or a sequence of object-id
and serial pairs giving new serials for objects whose ids were
passed to previous store calls in the same transaction. The serial
can be the special value ZODB.ConflictResolution.ResolvedSerial to
indicate that a conflict occurred and that the object should be
invalidated.
The return value can also be a sequence of object ids, as
described in IMultiCommitStorage.tpc_vote.
After the tpc_vote call, all solved conflicts must have been notified,
either from tpc_vote or store for objects passed to store.
"""
class IMultiCommitStorage(IStorage):
"""A multi-commit storage can commit multiple transactions at once.
It's likely that future versions of ZODB will require all storages
to provide this interface.
"""
def store(oid, serial, data, version, transaction):
"""Store data for the object id, oid.
See IStorage.store. For objects implementing this interface,
the return value is always None.
"""
def tpc_finish(transaction, func = lambda tid: None):
"""Finish the transaction, making any transaction changes permanent.
See IStorage.store. For objects implementing this interface,
the return value must be the committed tid. It is used to set the
serial for objects whose ids were passed to previous store calls
in the same transaction.
"""
def tpc_vote(transaction):
"""Provide a storage with an opportunity to veto a transaction
See IStorage.store. For objects implementing this interface,
the return value can be either None or a sequence of oids for which
a conflict was resolved.
"""
class IStorageRestoreable(IStorage):
"""Copying Transactions
......@@ -948,8 +974,8 @@ class IStorageUndoable(IStorage):
This method must only be called in the first phase of
two-phase commit (after tpc_begin but before tpc_vote). It
returns a serial (transaction id) and a sequence of object ids
for objects affected by the transaction.
for objects affected by the transaction. The serial is ignored
and may be None.
"""
# Used by DB (Actually, by TransactionalUndo)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment