List Info

Thread: Re: Any standard for two phase commit APIs?




Re: Any standard for two phase commit APIs?
country flaguser name
Thailand
2008-01-18 07:07:24
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 <stuartstuartbishop.net>
http://www.stuartbishop.
net/


_______________________________________________
DB-SIG maillist  -  DB-SIGpython.org
http:/
/mail.python.org/mailman/listinfo/db-sig

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )