Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
Commits
a2dea432
Commit
a2dea432
authored
Aug 08, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
4467ebea
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
3 deletions
+27
-3
go/zodb/db.go
go/zodb/db.go
+26
-3
go/zodb/zodb.go
go/zodb/zodb.go
+1
-0
No files found.
go/zodb/db.go
View file @
a2dea432
...
...
@@ -20,8 +20,11 @@
package
zodb
// application-level database handle.
// TODO: handle invalidations
import
(
"context"
"fmt"
"sort"
"sync"
"time"
...
...
@@ -81,8 +84,27 @@ type ConnOptions struct {
// Open must be called under transaction.
// Opened connection must be used only under the same transaction and only
// until that transaction is complete.
func
(
db
*
DB
)
Open
(
ctx
context
.
Context
,
opt
*
ConnOptions
)
(
*
Connection
,
error
)
{
// XXX err ctx
func
(
db
*
DB
)
Open
(
ctx
context
.
Context
,
opt
*
ConnOptions
)
(
_
*
Connection
,
err
error
)
{
defer
func
()
{
if
err
==
nil
{
return
}
var
argv
[]
interface
{}
if
opt
.
At
!=
0
{
argv
=
append
(
argv
,
fmt
.
Sprintf
(
"at=%s"
,
opt
.
At
))
}
if
opt
.
NoSync
{
argv
=
append
(
argv
,
"nosync"
)
}
err
=
&
OpError
{
URL
:
db
.
stor
.
URL
(),
Op
:
"open db"
,
Args
:
argv
,
Err
:
err
,
}
}()
txn
:=
transaction
.
Current
(
ctx
)
...
...
@@ -140,6 +162,7 @@ func (db *DB) get(at Tid) *Connection {
// search through window of X previous connections and find out the one
// with minimal distance to get to state @at. If all connections are to
// distant - create connection anew.
//
// XXX search not only previous, but future too? (we can get back to
// past by invalidating what was later changed)
const
X
=
10
// XXX hardcoded
...
...
@@ -168,7 +191,7 @@ func (db *DB) get(at Tid) *Connection {
if
conn
.
db
!=
db
{
panic
(
"DB.get: foreign connection in the pool"
)
}
if
conn
.
txn
!=
nil
)
{
if
conn
.
txn
!=
nil
{
panic
(
"DB.get: live connection in the pool"
)
}
...
...
go/zodb/zodb.go
View file @
a2dea432
...
...
@@ -311,6 +311,7 @@ func (e *OpError) Error() string {
if
e
.
Args
!=
nil
{
s
+=
fmt
.
Sprintf
(
" %s"
,
e
.
Args
)
}
// XXX if e.Err = OpError with the same URL - don't print URL twice.
s
+=
": "
+
e
.
Err
.
Error
()
return
s
}
...
...
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