watch: refactoring required for the client watch
This change precedes the client watch implementation and contains
refactoring with some minor fixes. The intention is to reuse more
code.
The main parts are:
- v23/syncbase/nosql: rename Stream to ScanStream and extract
common Stream interface from ScanStream and ResultStream
(also WatchStream is coming)
- move Watch methods from server/nosql/database.go to
server/nosql/database_watch.go
- move watch log helpers from watchable/util.go to
watchable/watcher.go
- move the WatchLogBatch() func from vsync/ to watchable/
together with the test
Change-Id: Iaab18a1ec6dd218e85284bd994ed71e766feab26
diff --git a/services/syncbase/server/watchable/transaction.go b/services/syncbase/server/watchable/transaction.go
index fb82f72..f557ca7 100644
--- a/services/syncbase/server/watchable/transaction.go
+++ b/services/syncbase/server/watchable/transaction.go
@@ -142,7 +142,7 @@
timestamp := tx.st.clock.Now().UnixNano()
seq := tx.st.seq
for i, op := range tx.ops {
- key := getLogEntryKey(seq)
+ key := logEntryKey(seq)
value := &LogEntry{
Op: op,
CommitTimestamp: timestamp,
@@ -248,6 +248,8 @@
// StoreReader interface is required since this is a Get operation.
func GetAtVersion(ctx *context.T, st store.StoreReader, key, valbuf, version []byte) ([]byte, error) {
switch w := st.(type) {
+ case *snapshot:
+ return getAtVersion(w.isn, key, valbuf, version)
case *transaction:
w.mu.Lock()
defer w.mu.Unlock()