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
cf2f3cef
Commit
cf2f3cef
authored
Mar 11, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
7f63e821
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
57 deletions
+8
-57
go/zodb/connection.go
go/zodb/connection.go
+1
-0
go/zodb/persistent_test.go
go/zodb/persistent_test.go
+7
-57
No files found.
go/zodb/connection.go
View file @
cf2f3cef
...
...
@@ -157,6 +157,7 @@ const (
//
// Object state is used once and then won't be used for a long time.
// There is no reason to preserve object state in cache.
// XXX Don't pollute ...
PCacheNonTemporal
// XXX PCachePolicy ?
)
...
...
go/zodb/persistent_test.go
View file @
cf2f3cef
...
...
@@ -216,14 +216,8 @@ type tPersistentDB struct {
stor
IStorage
db
*
DB
head
Tid
// last committed transaction
commitq
[]
toCommit
// queue to be committed
}
// XXX place? name?
type
toCommit
struct
{
oid
Oid
value
string
head
Tid
// last committed transaction
commitq
[]
IPersistent
// queue to be committed
}
// tPersistentConn represents testing Connection. XXX -> tConn ?
...
...
@@ -283,22 +277,17 @@ func (t *tPersistentDB) Close() {
//
// The commit is performed by Commit.
func
(
t
*
tPersistentDB
)
Add
(
oid
Oid
,
value
string
)
{
t
.
commitq
=
append
(
t
.
commitq
,
toCommit
{
oid
,
value
})
obj
:=
NewMyObject
(
nil
)
// XXX hack - goes without jar
obj
.
oid
=
oid
obj
.
value
=
value
t
.
commitq
=
append
(
t
.
commitq
,
obj
)
}
// Commit commits objects queued by Add.
func
(
t
*
tPersistentDB
)
Commit
()
{
t
.
Helper
()
var
objv
[]
IPersistent
for
_
,
tc
:=
range
t
.
commitq
{
obj
:=
NewMyObject
(
nil
)
// XXX hack - goes without jar
obj
.
oid
=
tc
.
oid
obj
.
value
=
tc
.
value
objv
=
append
(
objv
,
obj
)
}
head
,
err
:=
ZPyCommit
(
t
.
zurl
,
t
.
head
,
objv
...
)
head
,
err
:=
ZPyCommit
(
t
.
zurl
,
t
.
head
,
t
.
commitq
...
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
@@ -455,47 +444,8 @@ func testPersistentDB(t0 *testing.T, rawcache bool) {
tdb
.
Commit
()
at1
:=
tdb
.
head
/*
// create test db via py with 2 objects
// XXX hack as _objX go without jar.
_obj1 := NewMyObject(nil); _obj1.oid = 101; _obj1.value = "init"
_obj2 := NewMyObject(nil); _obj2.oid = 102; _obj2.value = "db"
at0, err := ZPyCommit(zurl, 0, _obj1, _obj2); X(err)
_obj1.value = "hello"
_obj2.value = "world"
at1, err := ZPyCommit(zurl, at0, _obj1, _obj2); X(err)
// open connection to it via zodb/go
ctx := context.Background()
stor, err := Open(ctx, zurl, &OpenOptions{ReadOnly: true, NoCache: !rawcache}); X(err)
db := NewDB(stor)
defer func() {
err := db.Close(); X(err)
}()
// testopen opens new db transaction/connection and wraps it with tPersistentDB.
testopen := func(opt *ConnOptions) *tPersistentDB {
t0.Helper()
txn, ctx := transaction.New(context.Background())
conn, err := db.Open(ctx, opt); X(err)
assert.Same(conn.db, db)
assert.Same(conn.txn, txn)
return &tPersistentDB{
T: t0,
txn: txn,
ctx: ctx,
conn: conn,
}
}
*/
db
:=
tdb
.
db
t1
:=
tdb
.
Open
(
&
ConnOptions
{})
t
:=
t1
assert
.
Equal
(
t
.
conn
.
At
(),
at1
)
...
...
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