Commit 79f54dcb authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 27120bd7
......@@ -146,6 +146,7 @@ type Transaction interface {
// XXX map[string]interface{} (objects must be simple values serialized with pickle or json, not "instances")
Extension() string
// XXX +Note, SetUser, ...
// Status returns current status of the transaction.
......@@ -181,7 +182,7 @@ type Transaction interface {
// Join must be called before transaction completion begins.
Join(dm DataManager)
// RegisterSync registers sync to be notified in this transaction boundary events.
// RegisterSync registers sync to be notified of this transaction boundary events.
//
// See Synchronizer for details.
//
......@@ -194,8 +195,8 @@ type Transaction interface {
// New creates new transaction.
//
// XXX the transaction will be associated with ctx (txnCtx derives from ctx + associates txn)
// XXX nested transactions are not supported.
// The transaction will be associated with new context derived from ctx.
// Nested transactions are not supported.
func New(ctx context.Context) (txn Transaction, txnCtx context.Context) {
return newTxn(ctx)
}
......@@ -247,9 +248,8 @@ type DataManager interface {
//
// It should make all changes to data modified by this transaction persist.
//
// This should never fail. If this returns an error, the XXX
// database is not expected to maintain consistency; it's a
// serious error.
// This should never fail. If this returns an error, the database is
// not expected to maintain consistency; it's a serious error.
TPCFinish(ctx context.Context, txn Transaction) error
// TPCAbort should Abort a transaction.
......@@ -291,8 +291,6 @@ type Synchronizer interface {
//
// On return ok indicates whether f succeeded, and the error, depending on ok,
// is either the error from f, or the error from transaction commit.
//
// XXX + note?
func With(ctx context.Context, f func(context.Context) error) (ok bool, _ error) {
txn, ctx := New(ctx)
err := f(ctx)
......
// Copyright (c) 2001, 2002 Zope Foundation and Contributors.
// All Rights Reserved.
//
// Copyright (C) 2018 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This software is subject to the provisions of the Zope Public License,
// Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
// THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
// WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
// FOR A PARTICULAR PURPOSE.
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 3, or (at your
// option) any later version, as published by the Free Software Foundation.
//
// You can also Link and Combine this program with other software covered by
// the terms of any of the Free Software licenses or any of the Open Source
// Initiative approved licenses and Convey the resulting work. Corresponding
// source of such a combination shall include the source code for all other
// software used.
//
// This program is distributed WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
package transaction
......@@ -33,11 +39,11 @@ type transaction struct {
extension string // XXX
}
// ctxKey is type private to transaction package, used as key in contexts.
// ctxKey is the type private to transaction package, used as key in contexts.
type ctxKey struct{}
// getTxn returns transaction associated with provided context.
// nil is returned is there is no association.
// nil is returned if there is no association.
func getTxn(ctx context.Context) *transaction {
t := ctx.Value(ctxKey{})
if t == nil {
......@@ -158,22 +164,6 @@ func (txn *transaction) Abort() {
// XXX return error?
}
// checkNotYetCompleting asserts that transaction completion has not yet began.
//
// and panics if the assert fails.
// must be called with .mu held.
//
// XXX place
func (txn *transaction) checkNotYetCompleting(who string) {
switch txn.status {
case Active: // XXX + Doomed ?
// ok
default:
panic("transaction: " + who + ": transaction completion already began")
}
}
// Join implements Transaction.
func (txn *transaction) Join(dm DataManager) {
txn.mu.Lock()
......@@ -196,6 +186,19 @@ func (txn *transaction) RegisterSync(sync Synchronizer) {
txn.syncv = append(txn.syncv, sync)
}
// checkNotYetCompleting asserts that transaction completion has not yet began.
//
// and panics if the assert fails.
// must be called with .mu held.
func (txn *transaction) checkNotYetCompleting(who string) {
switch txn.status {
case Active: // XXX + Doomed ?
// ok
default:
panic("transaction: " + who + ": transaction completion already began")
}
}
// ---- meta ----
......
// Copyright (c) 2001, 2002 Zope Foundation and Contributors.
// All Rights Reserved.
//
// Copyright (C) 2018 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This software is subject to the provisions of the Zope Public License,
// Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
// THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
// WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
// FOR A PARTICULAR PURPOSE.
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 3, or (at your
// option) any later version, as published by the Free Software Foundation.
//
// You can also Link and Combine this program with other software covered by
// the terms of any of the Free Software licenses or any of the Open Source
// Initiative approved licenses and Convey the resulting work. Corresponding
// source of such a combination shall include the source code for all other
// software used.
//
// This program is distributed WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
package transaction
......
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