Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
ee384083
Commit
ee384083
authored
Jul 24, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
2e93d7e4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
22 deletions
+25
-22
go/transaction/transaction.go
go/transaction/transaction.go
+25
-22
No files found.
go/transaction/transaction.go
View file @
ee384083
...
...
@@ -51,9 +51,12 @@ import (
// UnregisterSynch(synch Synchronizer)
// }
// Transaction represents
running
transaction.
// Transaction represents
a
transaction.
//
// ... and should be completed by either Commit or Abort.
// ... and should be completed by user via either Commit or Abort.
//
// Before completion, if there are changes to managed data, corresponding
// DataManager(s) must join the transaction to participate in the completion.
type
Transaction
interface
{
User
()
string
// user name associated with transaction
Description
()
string
// description of transaction
...
...
@@ -63,35 +66,36 @@ type Transaction interface {
// Commit finalizes the transaction.
//
//
This executes the two-phase commit algorithm for all DataManagers
// associated with the transaction.
//
Commit completes the transaction by executing the two-phase commit
// a
lgorithm for all DataManagers a
ssociated with the transaction.
Commit
(
ctx
context
.
Context
)
error
// Abort aborts the transaction.
//
// This is called from the application. This can only be called XXX
// before the two-phase commit protocol has been started. XXX
// Abort completes the transaction by executing Abort on all
// DataManagers associated with it.
Abort
()
// XXX + Doom?
// Join associates a DataManager to the transaction.
//
// Only associated data managers will participate in the transaction commit.
// Only associated data managers will participate in the transaction
// completion - commit or abort.
//
// Join must be called before transaction completion begins.
Join
(
DataManager
)
// XXX SetData(key interface{}, data interface{})
// XXX GetData(key interface{}) interface{}, ok
}
// // XXX
// type Participant interface {
// }
// DataManager manages data and can transactionally persist it.
//
// If DataManager is registered to transaction via Transaction.Join, it will
// participate in that transaction commit or abort.
// participate in that transaction completion - commit or abort. In other words
// a data manager should join to corresponding transaction when it sees there
// are modifications to data it manages.
type
DataManager
interface
{
// Abort should abort all modifications to managed data.
//
...
...
@@ -110,15 +114,15 @@ type DataManager interface {
// commits (if TPCFinish is called later). If TPCAbort is called
// later, changes must not persist.
//
// This includes conflict detection and handling. If no conflicts or
// errors occur, the committ
er should be prepared to make the
// changes persist when TPCFinish is called.
// This should include conflict detection and handling. If no conflicts
// or errors occur, the data manag
er should be prepared to make the
// changes persist when TPCFinish is called.
Commit
(
ctx
context
.
Context
,
txn
Transaction
)
error
// TPCVote should verify that a
committ
er can commit the transaction.
// TPCVote should verify that a
data manag
er can commit the transaction.
//
// This is the last chance for a committer to vote 'no'. A
// committ
er votes 'no' by returning an error.
// This is the last chance for a data manager to vote 'no'. A data
// manag
er votes 'no' by returning an error.
TPCVote
(
ctx
context
.
Context
,
txn
Transaction
)
error
// TPCFinish should indicate confirmation that the transaction is done.
...
...
@@ -152,8 +156,7 @@ type Synchronizer interface {
// AfterCompletion is called by the transaction after completing a commit.
AfterCompletion
(
txn
Transaction
)
// NewTransaction is called at the start of a transaction.
// XXX -> TxnStart ?
// XXX + ctx, error (it needs to ask storage for last tid)
NewTransaction
(
txn
Transaction
)
// // NewTransaction is called at the start of a transaction.
// // XXX + ctx, error (it needs to ask storage for last tid)
// NewTransaction(txn Transaction)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment