veyron2/storage/vstore: Refactor dependencies in vstore.
Extract implementations of storage.Transaction and storage.Object into
vstore/primitives. This breaks unnecessary dependencies that the
primitives previously had on vstore.VStore.
Change-Id: Iab600cf42151f48bbbb872bca2b20d8ccd03b8ba
diff --git a/examples/storage/mdb/mdb_init/main.go b/examples/storage/mdb/mdb_init/main.go
index 0cd0f7b..e5abab6 100644
--- a/examples/storage/mdb/mdb_init/main.go
+++ b/examples/storage/mdb/mdb_init/main.go
@@ -27,6 +27,7 @@
"veyron2/security"
"veyron2/storage"
"veyron2/storage/vstore"
+ "veyron2/storage/vstore/primitives"
"veyron2/vlog"
)
@@ -185,7 +186,7 @@
// newTransaction starts a new transaction.
func (st *state) newTransaction() {
- st.transaction = vstore.NewTransaction()
+ st.transaction = primitives.NewTransaction()
}
// commit commits the current transaction.
diff --git a/examples/todos/test/store_test.go b/examples/todos/test/store_test.go
index 2d4e541..1131530 100644
--- a/examples/todos/test/store_test.go
+++ b/examples/todos/test/store_test.go
@@ -21,7 +21,7 @@
bb "veyron/lib/testutil/blackbox"
"veyron2/storage"
- "veyron2/storage/vstore"
+ "veyron2/storage/vstore/primitives"
"veyron2/vom"
)
@@ -121,7 +121,7 @@
// Create lists.
{
// NOTE(sadovsky): Currently, we can't put /x/y until we put / and /x.
- tr := vstore.NewTransaction()
+ tr := primitives.NewTransaction()
put(t, st, tr, "/", newDir())
put(t, st, tr, "/lists", newDir())
put(t, st, tr, "/lists/drinks", newList())
@@ -131,7 +131,7 @@
// Add some todos.
{
- tr := vstore.NewTransaction()
+ tr := primitives.NewTransaction()
// NOTE(sadovsky): It feels awkward to create my own names (ids) for these
// Todo objects. I'd like some way to create them in some "directory"
// without explicitly naming them. I.e. in this case I want to think of the
@@ -144,7 +144,7 @@
// Verify some of the photos.
{
- tr := vstore.NewTransaction()
+ tr := primitives.NewTransaction()
todo := getTodo(t, st, tr, "/lists/drinks/Todos/0")
if todo.Text != "milk" {
t.Errorf("Expected %q, got %q", "milk", todo.Text)
@@ -152,7 +152,7 @@
}
{
- tr := vstore.NewTransaction()
+ tr := primitives.NewTransaction()
todo := getTodo(t, st, tr, "/lists/snacks/Todos/0")
if todo.Text != "chips" {
t.Errorf("Expected %q, got %q", "chips", todo.Text)
@@ -161,7 +161,7 @@
// Move a todo item from one list to another.
{
- tr := vstore.NewTransaction()
+ tr := primitives.NewTransaction()
todo := getTodo(t, st, tr, "/lists/drinks/Todos/1")
// NOTE(sadovsky): Remove works for map entries, but not yet for slices.
// Instead, we read the list, prune it, and write it back.
@@ -176,7 +176,7 @@
// Verify that the original todo is no longer there.
// TODO(sadovsky): Use queries to verify that both lists have changed.
{
- tr := vstore.NewTransaction()
+ tr := primitives.NewTransaction()
// Note, this will be much prettier in veyron2.
_, file, line, _ := runtime.Caller(1)
path := "/lists/drinks/1"
diff --git a/examples/todos/todos_init/main.go b/examples/todos/todos_init/main.go
index 68a233c..de829b3 100644
--- a/examples/todos/todos_init/main.go
+++ b/examples/todos/todos_init/main.go
@@ -24,6 +24,7 @@
"veyron2/security"
"veyron2/storage"
"veyron2/storage/vstore"
+ "veyron2/storage/vstore/primitives"
"veyron2/vlog"
)
@@ -96,7 +97,7 @@
// newTransaction starts a new transaction.
func (st *state) newTransaction() {
- st.transaction = vstore.NewTransaction()
+ st.transaction = primitives.NewTransaction()
}
// commit commits the current transaction.
diff --git a/services/mgmt/application/impl/invoker.go b/services/mgmt/application/impl/invoker.go
index 44588d2..6273e54 100644
--- a/services/mgmt/application/impl/invoker.go
+++ b/services/mgmt/application/impl/invoker.go
@@ -8,7 +8,7 @@
"veyron2/ipc"
"veyron2/services/mgmt/application"
"veyron2/storage"
- "veyron2/storage/vstore"
+ "veyron2/storage/vstore/primitives"
"veyron2/vlog"
)
@@ -100,7 +100,7 @@
if version == "" {
return errInvalidSuffix
}
- transaction := vstore.NewTransaction()
+ transaction := primitives.NewTransaction()
var entry storage.Stat
for _, profile := range profiles {
path := path.Join("/applications", name, profile, version)
@@ -130,7 +130,7 @@
if err != nil {
return err
}
- transaction := vstore.NewTransaction()
+ transaction := primitives.NewTransaction()
path := path.Join("/applications", name, profile)
if version != "" {
path += "/" + version
diff --git a/services/mgmt/profile/impl/invoker.go b/services/mgmt/profile/impl/invoker.go
index f8e7a95..0e77181 100644
--- a/services/mgmt/profile/impl/invoker.go
+++ b/services/mgmt/profile/impl/invoker.go
@@ -8,7 +8,7 @@
"veyron2/ipc"
"veyron2/storage"
- "veyron2/storage/vstore"
+ "veyron2/storage/vstore/primitives"
"veyron2/vlog"
)
@@ -54,7 +54,7 @@
func (i *invoker) Put(context ipc.Context, profile profile.Specification) error {
vlog.VI(0).Infof("%v.Put(%v)", i.suffix, profile)
- transaction := vstore.NewTransaction()
+ transaction := primitives.NewTransaction()
path := path.Join("/profiles", i.suffix)
if err := makeParentNodes(i.store, transaction, path); err != nil {
return err
@@ -71,7 +71,7 @@
func (i *invoker) Remove(context ipc.Context) error {
vlog.VI(0).Infof("%v.Remove(%v)", i.suffix)
- transaction := vstore.NewTransaction()
+ transaction := primitives.NewTransaction()
path := path.Join("/profiles", i.suffix)
object := i.store.Bind(path)
found, err := object.Exists(transaction)