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
adb2ada3
Commit
adb2ada3
authored
Mar 12, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
go/zodb: Cosmetics
More comments, typos, ...
parent
1e6aeeee
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
11 deletions
+18
-11
go/zodb/connection.go
go/zodb/connection.go
+5
-1
go/zodb/persistent_test.go
go/zodb/persistent_test.go
+9
-6
go/zodb/storage.go
go/zodb/storage.go
+4
-4
No files found.
go/zodb/connection.go
View file @
adb2ada3
...
@@ -125,7 +125,10 @@ type LiveCache struct {
...
@@ -125,7 +125,10 @@ type LiveCache struct {
}
}
// LiveCacheControl is the interface that allows applications to influence
// LiveCacheControl is the interface that allows applications to influence
// Connection's decisions with respect to Connection's live cache.
// Connection's decisions with respect to Connection's LiveCache.
//
// See Connection.Cache and LiveCache.SetControl for how to install
// LiveCacheControl on a connection's live cache.
type
LiveCacheControl
interface
{
type
LiveCacheControl
interface
{
// PCacheClassify is called to classify an object and returns live
// PCacheClassify is called to classify an object and returns live
// cache policy that should be used for this object.
// cache policy that should be used for this object.
...
@@ -210,6 +213,7 @@ func (e *wrongClassError) Error() string {
...
@@ -210,6 +213,7 @@ func (e *wrongClassError) Error() string {
// Get lookups object corresponding to oid in the cache.
// Get lookups object corresponding to oid in the cache.
//
//
// If object is found, it is guaranteed to stay in live cache while the caller keeps reference to it.
// If object is found, it is guaranteed to stay in live cache while the caller keeps reference to it.
// LiveCacheControl can be used to extend that guarantee.
func
(
cache
*
LiveCache
)
Get
(
oid
Oid
)
IPersistent
{
func
(
cache
*
LiveCache
)
Get
(
oid
Oid
)
IPersistent
{
// 1. lookup in pinned objects (likely hottest ones)
// 1. lookup in pinned objects (likely hottest ones)
obj
:=
cache
.
pinned
[
oid
]
obj
:=
cache
.
pinned
[
oid
]
...
...
go/zodb/persistent_test.go
View file @
adb2ada3
...
@@ -229,9 +229,9 @@ type tConnection struct {
...
@@ -229,9 +229,9 @@ type tConnection struct {
*
testing
.
T
*
testing
.
T
// a transaction and DB connection opened under it
// a transaction and DB connection opened under it
txn
transaction
.
Transaction
txn
transaction
.
Transaction
ctx
context
.
Context
ctx
context
.
Context
conn
*
Connection
conn
*
Connection
}
}
// testdb creates and initializes new test database.
// testdb creates and initializes new test database.
...
@@ -597,8 +597,8 @@ func testPersistentDB(t0 *testing.T, rawcache bool) {
...
@@ -597,8 +597,8 @@ func testPersistentDB(t0 *testing.T, rawcache bool) {
t
.
checkObj
(
obj2
,
102
,
InvalidTid
,
GHOST
,
0
)
t
.
checkObj
(
obj2
,
102
,
InvalidTid
,
GHOST
,
0
)
// obj2 data should be new
// obj2 data should be new
t
.
PActivate
(
obj1
)
;
t
.
PActivate
(
obj1
)
t
.
PActivate
(
obj2
)
;
t
.
PActivate
(
obj2
)
t
.
checkObj
(
obj1
,
101
,
at1
,
UPTODATE
,
1
,
"hello"
)
t
.
checkObj
(
obj1
,
101
,
at1
,
UPTODATE
,
1
,
"hello"
)
t
.
checkObj
(
obj2
,
102
,
at2
,
UPTODATE
,
1
,
"kitty"
)
t
.
checkObj
(
obj2
,
102
,
at2
,
UPTODATE
,
1
,
"kitty"
)
...
@@ -613,6 +613,9 @@ func testPersistentDB(t0 *testing.T, rawcache bool) {
...
@@ -613,6 +613,9 @@ func testPersistentDB(t0 *testing.T, rawcache bool) {
t2
.
Abort
()
t2
.
Abort
()
assert
.
Equal
(
db
.
pool
,
[]
*
Connection
{
t1
.
conn
,
t2
.
conn
})
assert
.
Equal
(
db
.
pool
,
[]
*
Connection
{
t1
.
conn
,
t2
.
conn
})
// ---- Resync ----
// open new connection in nopool mode to verify resync
// open new connection in nopool mode to verify resync
t4
:=
tdb
.
Open
(
&
ConnOptions
{
NoPool
:
true
})
t4
:=
tdb
.
Open
(
&
ConnOptions
{
NoPool
:
true
})
t
=
t4
t
=
t4
...
@@ -685,7 +688,7 @@ func testPersistentDB(t0 *testing.T, rawcache bool) {
...
@@ -685,7 +688,7 @@ func testPersistentDB(t0 *testing.T, rawcache bool) {
t
.
checkObj
(
robj1
,
101
,
InvalidTid
,
GHOST
,
0
)
t
.
checkObj
(
robj1
,
101
,
InvalidTid
,
GHOST
,
0
)
t
.
checkObj
(
robj2
,
102
,
at2
,
UPTODATE
,
0
,
"kitty"
)
t
.
checkObj
(
robj2
,
102
,
at2
,
UPTODATE
,
0
,
"kitty"
)
// Resync ↓ (at
1
-> at0; to outside δtail coverage)
// Resync ↓ (at
2
-> at0; to outside δtail coverage)
t
.
Abort
()
t
.
Abort
()
assert
.
Equal
(
db
.
pool
,
[]
*
Connection
{
t1
.
conn
,
t2
.
conn
})
assert
.
Equal
(
db
.
pool
,
[]
*
Connection
{
t1
.
conn
,
t2
.
conn
})
t
.
Resync
(
at0
)
t
.
Resync
(
at0
)
...
...
go/zodb/storage.go
View file @
adb2ada3
...
@@ -118,7 +118,7 @@ func Open(ctx context.Context, zurl string, opt *OpenOptions) (IStorage, error)
...
@@ -118,7 +118,7 @@ func Open(ctx context.Context, zurl string, opt *OpenOptions) (IStorage, error)
cache
=
NewCache
(
storDriver
,
128
*
4
*
1024
)
cache
=
NewCache
(
storDriver
,
128
*
4
*
1024
)
// FIXME teach cache for watching and remove vvv
// FIXME teach cache for watching and remove vvv
log
.
Printf
(
"zodb: FIXME: open %s: cache is not ready for invalidations"
+
log
.
Printf
(
"zodb: FIXME: open %s:
raw
cache is not ready for invalidations"
+
" -> NoCache forced"
,
zurl
)
" -> NoCache forced"
,
zurl
)
cache
=
nil
cache
=
nil
}
}
...
@@ -135,7 +135,7 @@ func Open(ctx context.Context, zurl string, opt *OpenOptions) (IStorage, error)
...
@@ -135,7 +135,7 @@ func Open(ctx context.Context, zurl string, opt *OpenOptions) (IStorage, error)
watchCancel
:
make
(
map
[
chan
<-
Event
]
chan
struct
{}),
watchCancel
:
make
(
map
[
chan
<-
Event
]
chan
struct
{}),
}
}
go
stor
.
watcher
()
// stoped on close
go
stor
.
watcher
()
// stop
p
ed on close
return
stor
,
nil
return
stor
,
nil
}
}
...
@@ -145,7 +145,7 @@ func Open(ctx context.Context, zurl string, opt *OpenOptions) (IStorage, error)
...
@@ -145,7 +145,7 @@ func Open(ctx context.Context, zurl string, opt *OpenOptions) (IStorage, error)
// storage represents storage opened via Open.
// storage represents storage opened via Open.
//
//
// it provides a small cache on top of raw storage driver to implement prefetch
// it provides a small cache on top of raw storage driver to implement prefetch
// and other storage-independe
d
higher-level functionality.
// and other storage-independe
nt
higher-level functionality.
type
storage
struct
{
type
storage
struct
{
driver
IStorageDriver
driver
IStorageDriver
l1cache
*
Cache
// can be =nil, if opened with NoCache
l1cache
*
Cache
// can be =nil, if opened with NoCache
...
@@ -281,7 +281,7 @@ func (s *storage) _watcher() error {
...
@@ -281,7 +281,7 @@ func (s *storage) _watcher() error {
req
.
ack
<-
s
.
head
req
.
ack
<-
s
.
head
}
}
// close all subscribers's watchq on watcher shutdow
// close all subscribers's watchq on watcher shutdow
n
defer
func
()
{
defer
func
()
{
addqFlush
()
addqFlush
()
for
watchq
:=
range
s
.
watchTab
{
for
watchq
:=
range
s
.
watchTab
{
...
...
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