syncbase/vsync: vdl for client-facing blob API.
Change-Id: If691e483a1359a20f38dd215579cccb42bdc0c50
diff --git a/services/syncbase/server/interfaces/sync.vdl b/services/syncbase/server/interfaces/sync.vdl
index 3bb3667..470d5b9 100644
--- a/services/syncbase/server/interfaces/sync.vdl
+++ b/services/syncbase/server/interfaces/sync.vdl
@@ -38,5 +38,5 @@
// BlobSync methods.
// FetchBlob returns the requested blob.
- FetchBlob() error {access.Read}
+ FetchBlob(br wire.BlobRef) error {access.Read}
}
diff --git a/services/syncbase/server/interfaces/sync.vdl.go b/services/syncbase/server/interfaces/sync.vdl.go
index b87397b..adb964f 100644
--- a/services/syncbase/server/interfaces/sync.vdl.go
+++ b/services/syncbase/server/interfaces/sync.vdl.go
@@ -47,7 +47,7 @@
JoinSyncGroupAtAdmin(ctx *context.T, sgName string, joinerName string, myInfo nosql.SyncGroupMemberInfo, opts ...rpc.CallOpt) (SyncGroup, error)
// BlobSync methods.
// FetchBlob returns the requested blob.
- FetchBlob(*context.T, ...rpc.CallOpt) error
+ FetchBlob(ctx *context.T, br nosql.BlobRef, opts ...rpc.CallOpt) error
}
// SyncClientStub adds universal methods to SyncClientMethods.
@@ -84,8 +84,8 @@
return
}
-func (c implSyncClientStub) FetchBlob(ctx *context.T, opts ...rpc.CallOpt) (err error) {
- err = v23.GetClient(ctx).Call(ctx, c.name, "FetchBlob", nil, nil, opts...)
+func (c implSyncClientStub) FetchBlob(ctx *context.T, i0 nosql.BlobRef, opts ...rpc.CallOpt) (err error) {
+ err = v23.GetClient(ctx).Call(ctx, c.name, "FetchBlob", []interface{}{i0}, nil, opts...)
return
}
@@ -218,7 +218,7 @@
JoinSyncGroupAtAdmin(ctx *context.T, call rpc.ServerCall, sgName string, joinerName string, myInfo nosql.SyncGroupMemberInfo) (SyncGroup, error)
// BlobSync methods.
// FetchBlob returns the requested blob.
- FetchBlob(*context.T, rpc.ServerCall) error
+ FetchBlob(ctx *context.T, call rpc.ServerCall, br nosql.BlobRef) error
}
// SyncServerStubMethods is the server interface containing
@@ -247,7 +247,7 @@
JoinSyncGroupAtAdmin(ctx *context.T, call rpc.ServerCall, sgName string, joinerName string, myInfo nosql.SyncGroupMemberInfo) (SyncGroup, error)
// BlobSync methods.
// FetchBlob returns the requested blob.
- FetchBlob(*context.T, rpc.ServerCall) error
+ FetchBlob(ctx *context.T, call rpc.ServerCall, br nosql.BlobRef) error
}
// SyncServerStub adds universal methods to SyncServerStubMethods.
@@ -291,8 +291,8 @@
return s.impl.JoinSyncGroupAtAdmin(ctx, call, i0, i1, i2)
}
-func (s implSyncServerStub) FetchBlob(ctx *context.T, call rpc.ServerCall) error {
- return s.impl.FetchBlob(ctx, call)
+func (s implSyncServerStub) FetchBlob(ctx *context.T, call rpc.ServerCall, i0 nosql.BlobRef) error {
+ return s.impl.FetchBlob(ctx, call, i0)
}
func (s implSyncServerStub) Globber() *rpc.GlobState {
@@ -341,6 +341,9 @@
{
Name: "FetchBlob",
Doc: "// BlobSync methods.\n// FetchBlob returns the requested blob.",
+ InArgs: []rpc.ArgDesc{
+ {"br", ``}, // nosql.BlobRef
+ },
Tags: []*vdl.Value{vdl.ValueOf(access.Tag("Read"))},
},
},
diff --git a/services/syncbase/server/nosql/database_bm.go b/services/syncbase/server/nosql/database_bm.go
new file mode 100644
index 0000000..65a1413
--- /dev/null
+++ b/services/syncbase/server/nosql/database_bm.go
@@ -0,0 +1,95 @@
+// Copyright 2015 The Vanadium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package nosql
+
+import (
+ wire "v.io/syncbase/v23/services/syncbase/nosql"
+ "v.io/syncbase/x/ref/services/syncbase/vsync"
+ "v.io/v23/context"
+ "v.io/v23/rpc"
+)
+
+////////////////////////////////////////////////////////////////////////////////
+// RPCs for managing blobs between Syncbase and its clients.
+
+func (d *databaseReq) CreateBlob(ctx *context.T, call rpc.ServerCall) (wire.BlobRef, error) {
+ if d.batchId != nil {
+ return wire.NullBlobRef, wire.NewErrBoundToBatch(ctx)
+ }
+ sd := vsync.NewSyncDatabase(d)
+ return sd.CreateBlob(ctx, call)
+}
+
+func (d *databaseReq) PutBlob(ctx *context.T, call wire.BlobManagerPutBlobServerCall, br wire.BlobRef) error {
+ if d.batchId != nil {
+ return wire.NewErrBoundToBatch(ctx)
+ }
+ sd := vsync.NewSyncDatabase(d)
+ return sd.PutBlob(ctx, call, br)
+}
+
+func (d *databaseReq) CommitBlob(ctx *context.T, call rpc.ServerCall, br wire.BlobRef) error {
+ if d.batchId != nil {
+ return wire.NewErrBoundToBatch(ctx)
+ }
+ sd := vsync.NewSyncDatabase(d)
+ return sd.CommitBlob(ctx, call, br)
+}
+
+func (d *databaseReq) GetBlobSize(ctx *context.T, call rpc.ServerCall, br wire.BlobRef) (uint64, error) {
+ if d.batchId != nil {
+ return 0, wire.NewErrBoundToBatch(ctx)
+ }
+ sd := vsync.NewSyncDatabase(d)
+ return sd.GetBlobSize(ctx, call, br)
+}
+
+func (d *databaseReq) DeleteBlob(ctx *context.T, call rpc.ServerCall, br wire.BlobRef) error {
+ if d.batchId != nil {
+ return wire.NewErrBoundToBatch(ctx)
+ }
+ sd := vsync.NewSyncDatabase(d)
+ return sd.DeleteBlob(ctx, call, br)
+}
+
+func (d *databaseReq) GetBlob(ctx *context.T, call wire.BlobManagerGetBlobServerCall, br wire.BlobRef, offset uint64) error {
+ if d.batchId != nil {
+ return wire.NewErrBoundToBatch(ctx)
+ }
+ sd := vsync.NewSyncDatabase(d)
+ return sd.GetBlob(ctx, call, br, offset)
+}
+
+func (d *databaseReq) FetchBlob(ctx *context.T, call wire.BlobManagerFetchBlobServerCall, br wire.BlobRef, priority uint64) error {
+ if d.batchId != nil {
+ return wire.NewErrBoundToBatch(ctx)
+ }
+ sd := vsync.NewSyncDatabase(d)
+ return sd.FetchBlob(ctx, call, br, priority)
+}
+
+func (d *databaseReq) PinBlob(ctx *context.T, call rpc.ServerCall, br wire.BlobRef) error {
+ if d.batchId != nil {
+ return wire.NewErrBoundToBatch(ctx)
+ }
+ sd := vsync.NewSyncDatabase(d)
+ return sd.PinBlob(ctx, call, br)
+}
+
+func (d *databaseReq) UnpinBlob(ctx *context.T, call rpc.ServerCall, br wire.BlobRef) error {
+ if d.batchId != nil {
+ return wire.NewErrBoundToBatch(ctx)
+ }
+ sd := vsync.NewSyncDatabase(d)
+ return sd.UnpinBlob(ctx, call, br)
+}
+
+func (d *databaseReq) KeepBlob(ctx *context.T, call rpc.ServerCall, br wire.BlobRef, rank uint64) error {
+ if d.batchId != nil {
+ return wire.NewErrBoundToBatch(ctx)
+ }
+ sd := vsync.NewSyncDatabase(d)
+ return sd.KeepBlob(ctx, call, br, rank)
+}
diff --git a/services/syncbase/server/nosql/database_sgm.go b/services/syncbase/server/nosql/database_sgm.go
index 62c905a..10ad323 100644
--- a/services/syncbase/server/nosql/database_sgm.go
+++ b/services/syncbase/server/nosql/database_sgm.go
@@ -5,9 +5,8 @@
package nosql
import (
- "v.io/syncbase/x/ref/services/syncbase/vsync"
-
wire "v.io/syncbase/v23/services/syncbase/nosql"
+ "v.io/syncbase/x/ref/services/syncbase/vsync"
"v.io/v23/context"
"v.io/v23/rpc"
"v.io/v23/verror"
diff --git a/services/syncbase/vsync/blob.go b/services/syncbase/vsync/blob.go
index a50b58c..7c98be0 100644
--- a/services/syncbase/vsync/blob.go
+++ b/services/syncbase/vsync/blob.go
@@ -5,14 +5,58 @@
package vsync
import (
+ wire "v.io/syncbase/v23/services/syncbase/nosql"
"v.io/v23/context"
"v.io/v23/rpc"
"v.io/v23/verror"
)
-//////////////////////////////////////////////////
-// Methods for blob fetch between Syncbases.
+////////////////////////////////////////////////////////////
+// RPCs for managing blobs between Syncbase and its clients.
-func (s *syncService) FetchBlob(ctx *context.T, call rpc.ServerCall) error {
+func (sd *syncDatabase) CreateBlob(ctx *context.T, call rpc.ServerCall) (wire.BlobRef, error) {
+ return wire.BlobRef(""), verror.NewErrNotImplemented(ctx)
+}
+
+func (sd *syncDatabase) PutBlob(ctx *context.T, call wire.BlobManagerPutBlobServerCall, br wire.BlobRef) error {
+ return verror.NewErrNotImplemented(ctx)
+}
+
+func (sd *syncDatabase) CommitBlob(ctx *context.T, call rpc.ServerCall, br wire.BlobRef) error {
+ return verror.NewErrNotImplemented(ctx)
+}
+
+func (sd *syncDatabase) GetBlobSize(ctx *context.T, call rpc.ServerCall, br wire.BlobRef) (uint64, error) {
+ return 0, verror.NewErrNotImplemented(ctx)
+}
+
+func (sd *syncDatabase) DeleteBlob(ctx *context.T, call rpc.ServerCall, br wire.BlobRef) error {
+ return verror.NewErrNotImplemented(ctx)
+}
+
+func (sd *syncDatabase) GetBlob(ctx *context.T, call wire.BlobManagerGetBlobServerCall, br wire.BlobRef, offset uint64) error {
+ return verror.NewErrNotImplemented(ctx)
+}
+
+func (sd *syncDatabase) FetchBlob(ctx *context.T, call wire.BlobManagerFetchBlobServerCall, br wire.BlobRef, priority uint64) error {
+ return verror.NewErrNotImplemented(ctx)
+}
+
+func (sd *syncDatabase) PinBlob(ctx *context.T, call rpc.ServerCall, br wire.BlobRef) error {
+ return verror.NewErrNotImplemented(ctx)
+}
+
+func (sd *syncDatabase) UnpinBlob(ctx *context.T, call rpc.ServerCall, br wire.BlobRef) error {
+ return verror.NewErrNotImplemented(ctx)
+}
+
+func (sd *syncDatabase) KeepBlob(ctx *context.T, call rpc.ServerCall, br wire.BlobRef, rank uint64) error {
+ return verror.NewErrNotImplemented(ctx)
+}
+
+////////////////////////////////////////////////////////////
+// RPC for blob fetch between Syncbases.
+
+func (s *syncService) FetchBlob(ctx *context.T, call rpc.ServerCall, br wire.BlobRef) error {
return verror.NewErrNotImplemented(ctx)
}