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
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 (
...
@@ -157,6 +157,7 @@ const (
//
//
// Object state is used once and then won't be used for a long time.
// 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.
// There is no reason to preserve object state in cache.
// XXX Don't pollute ...
PCacheNonTemporal
// XXX PCachePolicy ?
PCacheNonTemporal
// XXX PCachePolicy ?
)
)
...
...
go/zodb/persistent_test.go
View file @
cf2f3cef
...
@@ -216,14 +216,8 @@ type tPersistentDB struct {
...
@@ -216,14 +216,8 @@ type tPersistentDB struct {
stor
IStorage
stor
IStorage
db
*
DB
db
*
DB
head
Tid
// last committed transaction
head
Tid
// last committed transaction
commitq
[]
toCommit
// queue to be committed
commitq
[]
IPersistent
// queue to be committed
}
// XXX place? name?
type
toCommit
struct
{
oid
Oid
value
string
}
}
// tPersistentConn represents testing Connection. XXX -> tConn ?
// tPersistentConn represents testing Connection. XXX -> tConn ?
...
@@ -283,22 +277,17 @@ func (t *tPersistentDB) Close() {
...
@@ -283,22 +277,17 @@ func (t *tPersistentDB) Close() {
//
//
// The commit is performed by Commit.
// The commit is performed by Commit.
func
(
t
*
tPersistentDB
)
Add
(
oid
Oid
,
value
string
)
{
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.
// Commit commits objects queued by Add.
func
(
t
*
tPersistentDB
)
Commit
()
{
func
(
t
*
tPersistentDB
)
Commit
()
{
t
.
Helper
()
t
.
Helper
()
var
objv
[]
IPersistent
head
,
err
:=
ZPyCommit
(
t
.
zurl
,
t
.
head
,
t
.
commitq
...
)
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
...
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
...
@@ -455,47 +444,8 @@ func testPersistentDB(t0 *testing.T, rawcache bool) {
...
@@ -455,47 +444,8 @@ func testPersistentDB(t0 *testing.T, rawcache bool) {
tdb
.
Commit
()
tdb
.
Commit
()
at1
:=
tdb
.
head
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
db
:=
tdb
.
db
t1
:=
tdb
.
Open
(
&
ConnOptions
{})
t1
:=
tdb
.
Open
(
&
ConnOptions
{})
t
:=
t1
t
:=
t1
assert
.
Equal
(
t
.
conn
.
At
(),
at1
)
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