James Henstridge wrote:
> So is there any recommendations for what a two-phase
commit API should
> look like?
Here are the three obvious possibilities. The first is what
you already
have. The other two also allow access to all of PostgreSQL's
two phase
commit API and are functionally identical. All would work
fine for
integrating with the transaction managers I'm familiar with
(Z2, Z3, Storm).
The difference is just spelling. Any opinions?
conn = connect([...])
[... do work ...]
try:
xid = conn.prepare_transaction('xid%f' % random())
[... prepare other participants ...]
except:
conn.rollback_prepared(xid)
else:
conn.commit_prepared(xid)
conn = connect([...])
[... do work ...]
try:
trans = conn.prepare_transaction('xid%f' % random())
[... prepare other participants ...]
except:
trans.rollback()
else:
trans.commit()
conn = connect([...])
[... do work ...]
try:
trans = PreparedTransaction(con, 'xid%f' % random())
[... prepare other participants ...]
except:
trans.rollback()
else:
trans.commit()
--
Stuart Bishop <stuart stuartbishop.net>
http://www.stuartbishop.
net/
_______________________________________________
DB-SIG maillist - DB-SIG python.org
http:/
/mail.python.org/mailman/listinfo/db-sig
|