v.io/v23/services/syncbase: use interface{} for values from syncbase's Exec() and Watch()
Use interface{} for values from syncbase's Exec() and Watch(), to
match the interfaces of Put(), Get(), and Scan().
Reviewers might like to look at syncbase/model.go first to
see the changes to the public API.
In v.io/v23:
services/syncbase/types.vdl
StoreChange.Value is now an "any" (a *vom.RawBytes in
Go), rather than a []byte.
services/syncbase/service.vdl
There is a new error to indicate that a stream header is
badly formatted. Previously, the error in this case was
whatever error vom.Decode() returned; see database.go
syncbase/featuretests/client_v23_test.go
Now uses the Value() method on WatchChange, rather than
accessing its (now private) field directly.
syncbase/featuretests/restartability_v23_test.go
Now uses the Value() method on WatchChange, rather than
accessing its (now private) field directly.
syncbase/batch_test.go
Uses a Go type assertion in an interface{} rather than
ToValue() on a RawBytes.
syncbase/client_test.go
Use a testutil.WatchChangeTest struct instead of a
syncbase.WatchChange struct to hold the "wanted" values,
because syncbase.WatchChange's value field is now private.
Use testutil.WatchChangeEq() instead of
reflect.DeepEqual(), for the same reason.
syncbase/database.go
Uses a Go type assertion in an interface{} rather than
ToValue() on a RawBytes. This is where a new error is
returned rather than returning the error from ToValue();
see service.vdl.
syncbase/exec_test.go
Use interface{} instead of *vom.RawBytes in results from
Exec().
syncbase/model.go
ResultStream (from Exec()) now contains a vector of
interface{} instead of a vector of *vom.RawBytes.
WatchChange (from Watch()) no longer has a public field
"ValueBytes []byte" but now has a private value
"*vom.RawBytes" field. Clients are required to use the
pre-existing Value() method that fills in an interface{}.
syncbase/result_stream.go
Add a "decoded []interface{}" field to resultStream to
cache the decoded results from the Advance() call to the
Result() call. The reason for performing the decoding in
Advance() is because Advance() is permitted to signal an
error (such as a decoding error), while Result() may not.
Advance() is changed to decode the values in "curr" into
"decoded", and to return an error on decoding failures.
Result() is changed to return a vector of interface{},
rather than a vector of *vom.RawBytes.
syncbase/syncgroup_v23_test.go
Now uses the Value() method on WatchChange, rather than
accessing its (now private) field directly.
syncbase/watch_stream.go
The old, public "ValueBytes" field of WatchChange is now
private, andf called "value".
In v.io/x/ref:
cmd/sb/internal/writer/writer.go
getJustification() now uses a Go type switch rather than
a switch on VDL types, because it's working with
interface{} values rather than *vom.RawBytes values.
toRawString() and topJson now each take an interface{}
rather than a *vom.RawBytes.
cmd/sb/internal/writer/writer_test.go
Use interface{} instead of *vom.RawBytes in several
places.
services/syncbase/server/database_watch.go
In each of scanInitialState() and processLogBatch(),
convert the []byte value from leveldb to *voim.RawBytes
to add to the syncbase.StoreChange; see types.vdl.
services/syncbase/server/testutil/util.go
In CheckExec(), use interface{} instead of *vom.RawBytes.
Add struct WatchChangeTest to allow tests to construct
"wanted" values that have a ValueBytes field; the
corresponding field in WatchChange is now private; see
model.go.
Add func WatchChangeEq() that allows tests to compare a
WatchChange against a WatchChangeTest, since they can no
longer use reflect.DeepEqual().
MultiPart: 3/3
Change-Id: I8c13a536a21605341a2673e0b9b6958417d4b730
1 file changed