commit | 0883b8883c683e3fe95700d4fb5e1e1a0e41c479 | [log] [tgz] |
---|---|---|
author | Mike Burrows <m3b@google.com> | Thu Mar 31 14:05:20 2016 -0700 |
committer | Mike Burrows <m3b@google.com> | Thu Mar 31 14:05:20 2016 -0700 |
tree | 318c0dd0077c8a68d38fcb08aa87495fa0241b31 | |
parent | 694508a07be006e2ffb24d69bd9742bb206e6afd [diff] |
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 has ResultCount() int Result(int, interface{}) error calls instead of a single Result() []*vom.RawBytes call. 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. ervices/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: 2/3 Change-Id: I97a10de15156ee05043c5abe5b3dc53777bb4eb7
This repository contains a reference implementation of the Vanadium APIs.
Unlike the APIs in https://github.com/vanadium/go.v23, which promises to provide backward compatibility this repository makes no such promises.