| // 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. |
| |
| // This file was auto-generated by the vanadium vdl tool. |
| // Source: service.vdl |
| |
| // Package nosql defines the wire API for the NoSQL part of Syncbase. |
| package nosql |
| |
| import ( |
| // VDL system imports |
| "v.io/v23" |
| "v.io/v23/context" |
| "v.io/v23/rpc" |
| "v.io/v23/vdl" |
| |
| // VDL user imports |
| "v.io/v23/security/access" |
| "v.io/v23/services/permissions" |
| ) |
| |
| // DatabaseClientMethods is the client interface |
| // containing Database methods. |
| // |
| // Database represents a collection of Tables. Batches, queries, sync, watch, |
| // etc. all operate at the Database level. |
| // Database.Glob operates over Table names. |
| // |
| // TODO(sadovsky): Add Watch method. |
| type DatabaseClientMethods interface { |
| // Object provides access control for Vanadium objects. |
| // |
| // Vanadium services implementing dynamic access control would typically embed |
| // this interface and tag additional methods defined by the service with one of |
| // Admin, Read, Write, Resolve etc. For example, the VDL definition of the |
| // object would be: |
| // |
| // package mypackage |
| // |
| // import "v.io/v23/security/access" |
| // import "v.io/v23/services/permissions" |
| // |
| // type MyObject interface { |
| // permissions.Object |
| // MyRead() (string, error) {access.Read} |
| // MyWrite(string) error {access.Write} |
| // } |
| // |
| // If the set of pre-defined tags is insufficient, services may define their |
| // own tag type and annotate all methods with this new type. |
| // |
| // Instead of embedding this Object interface, define SetPermissions and |
| // GetPermissions in their own interface. Authorization policies will typically |
| // respect annotations of a single type. For example, the VDL definition of an |
| // object would be: |
| // |
| // package mypackage |
| // |
| // import "v.io/v23/security/access" |
| // |
| // type MyTag string |
| // |
| // const ( |
| // Blue = MyTag("Blue") |
| // Red = MyTag("Red") |
| // ) |
| // |
| // type MyObject interface { |
| // MyMethod() (string, error) {Blue} |
| // |
| // // Allow clients to change access via the access.Object interface: |
| // SetPermissions(acl access.Permissions, version string) error {Red} |
| // GetPermissions() (acl access.Permissions, version string, err error) {Blue} |
| // } |
| permissions.ObjectClientMethods |
| // Create creates the specified Table. |
| // If perms is nil, Permissions is inherited (copied) from the Database. |
| // relativeName must not contain slashes. |
| CreateTable(ctx *context.T, relativeName string, perms access.Permissions, opts ...rpc.CallOpt) error |
| // DeleteTable deletes the specified Table. |
| DeleteTable(ctx *context.T, relativeName string, opts ...rpc.CallOpt) error |
| // Create creates this Database. |
| // If perms is nil, Permissions is inherited (copied) from the App. |
| // Create requires the caller to have Write permission at the App. |
| Create(ctx *context.T, perms access.Permissions, opts ...rpc.CallOpt) error |
| // Delete deletes this Database. |
| Delete(*context.T, ...rpc.CallOpt) error |
| // BeginBatch creates a new batch. It returns an App-relative name for a |
| // Database handle bound to this batch. If this Database is already bound to a |
| // batch, BeginBatch() will fail with ErrBoundToBatch. |
| // |
| // Default concurrency semantics: |
| // - Reads inside a batch see a consistent snapshot, taken during |
| // BeginBatch(), and will not see the effect of writes inside the batch. |
| // - Commit() may fail with ErrConcurrentBatch, indicating that after |
| // BeginBatch() but before Commit(), some concurrent routine wrote to a key |
| // that matches a key or row-range read inside this batch. (Writes inside a |
| // batch cannot cause that batch's Commit() to fail.) |
| // - Other methods (e.g. Get) will never fail with error ErrConcurrentBatch, |
| // even if it is known that Commit() will fail with this error. |
| // |
| // Concurrency semantics can be configured using BatchOptions. |
| BeginBatch(ctx *context.T, bo BatchOptions, opts ...rpc.CallOpt) (string, error) |
| // Commit persists the pending changes to the database. |
| // If this Database is not bound to a batch, Commit() will fail with |
| // ErrNotBoundToBatch. |
| Commit(*context.T, ...rpc.CallOpt) error |
| // Abort notifies the server that any pending changes can be discarded. |
| // It is not strictly required, but it may allow the server to release locks |
| // or other resources sooner than if it was not called. |
| // If this Database is not bound to a batch, Abort() will fail with |
| // ErrNotBoundToBatch. |
| Abort(*context.T, ...rpc.CallOpt) error |
| } |
| |
| // DatabaseClientStub adds universal methods to DatabaseClientMethods. |
| type DatabaseClientStub interface { |
| DatabaseClientMethods |
| rpc.UniversalServiceMethods |
| } |
| |
| // DatabaseClient returns a client stub for Database. |
| func DatabaseClient(name string) DatabaseClientStub { |
| return implDatabaseClientStub{name, permissions.ObjectClient(name)} |
| } |
| |
| type implDatabaseClientStub struct { |
| name string |
| |
| permissions.ObjectClientStub |
| } |
| |
| func (c implDatabaseClientStub) CreateTable(ctx *context.T, i0 string, i1 access.Permissions, opts ...rpc.CallOpt) (err error) { |
| err = v23.GetClient(ctx).Call(ctx, c.name, "CreateTable", []interface{}{i0, i1}, nil, opts...) |
| return |
| } |
| |
| func (c implDatabaseClientStub) DeleteTable(ctx *context.T, i0 string, opts ...rpc.CallOpt) (err error) { |
| err = v23.GetClient(ctx).Call(ctx, c.name, "DeleteTable", []interface{}{i0}, nil, opts...) |
| return |
| } |
| |
| func (c implDatabaseClientStub) Create(ctx *context.T, i0 access.Permissions, opts ...rpc.CallOpt) (err error) { |
| err = v23.GetClient(ctx).Call(ctx, c.name, "Create", []interface{}{i0}, nil, opts...) |
| return |
| } |
| |
| func (c implDatabaseClientStub) Delete(ctx *context.T, opts ...rpc.CallOpt) (err error) { |
| err = v23.GetClient(ctx).Call(ctx, c.name, "Delete", nil, nil, opts...) |
| return |
| } |
| |
| func (c implDatabaseClientStub) BeginBatch(ctx *context.T, i0 BatchOptions, opts ...rpc.CallOpt) (o0 string, err error) { |
| err = v23.GetClient(ctx).Call(ctx, c.name, "BeginBatch", []interface{}{i0}, []interface{}{&o0}, opts...) |
| return |
| } |
| |
| func (c implDatabaseClientStub) Commit(ctx *context.T, opts ...rpc.CallOpt) (err error) { |
| err = v23.GetClient(ctx).Call(ctx, c.name, "Commit", nil, nil, opts...) |
| return |
| } |
| |
| func (c implDatabaseClientStub) Abort(ctx *context.T, opts ...rpc.CallOpt) (err error) { |
| err = v23.GetClient(ctx).Call(ctx, c.name, "Abort", nil, nil, opts...) |
| return |
| } |
| |
| // DatabaseServerMethods is the interface a server writer |
| // implements for Database. |
| // |
| // Database represents a collection of Tables. Batches, queries, sync, watch, |
| // etc. all operate at the Database level. |
| // Database.Glob operates over Table names. |
| // |
| // TODO(sadovsky): Add Watch method. |
| type DatabaseServerMethods interface { |
| // Object provides access control for Vanadium objects. |
| // |
| // Vanadium services implementing dynamic access control would typically embed |
| // this interface and tag additional methods defined by the service with one of |
| // Admin, Read, Write, Resolve etc. For example, the VDL definition of the |
| // object would be: |
| // |
| // package mypackage |
| // |
| // import "v.io/v23/security/access" |
| // import "v.io/v23/services/permissions" |
| // |
| // type MyObject interface { |
| // permissions.Object |
| // MyRead() (string, error) {access.Read} |
| // MyWrite(string) error {access.Write} |
| // } |
| // |
| // If the set of pre-defined tags is insufficient, services may define their |
| // own tag type and annotate all methods with this new type. |
| // |
| // Instead of embedding this Object interface, define SetPermissions and |
| // GetPermissions in their own interface. Authorization policies will typically |
| // respect annotations of a single type. For example, the VDL definition of an |
| // object would be: |
| // |
| // package mypackage |
| // |
| // import "v.io/v23/security/access" |
| // |
| // type MyTag string |
| // |
| // const ( |
| // Blue = MyTag("Blue") |
| // Red = MyTag("Red") |
| // ) |
| // |
| // type MyObject interface { |
| // MyMethod() (string, error) {Blue} |
| // |
| // // Allow clients to change access via the access.Object interface: |
| // SetPermissions(acl access.Permissions, version string) error {Red} |
| // GetPermissions() (acl access.Permissions, version string, err error) {Blue} |
| // } |
| permissions.ObjectServerMethods |
| // Create creates the specified Table. |
| // If perms is nil, Permissions is inherited (copied) from the Database. |
| // relativeName must not contain slashes. |
| CreateTable(call rpc.ServerCall, relativeName string, perms access.Permissions) error |
| // DeleteTable deletes the specified Table. |
| DeleteTable(call rpc.ServerCall, relativeName string) error |
| // Create creates this Database. |
| // If perms is nil, Permissions is inherited (copied) from the App. |
| // Create requires the caller to have Write permission at the App. |
| Create(call rpc.ServerCall, perms access.Permissions) error |
| // Delete deletes this Database. |
| Delete(rpc.ServerCall) error |
| // BeginBatch creates a new batch. It returns an App-relative name for a |
| // Database handle bound to this batch. If this Database is already bound to a |
| // batch, BeginBatch() will fail with ErrBoundToBatch. |
| // |
| // Default concurrency semantics: |
| // - Reads inside a batch see a consistent snapshot, taken during |
| // BeginBatch(), and will not see the effect of writes inside the batch. |
| // - Commit() may fail with ErrConcurrentBatch, indicating that after |
| // BeginBatch() but before Commit(), some concurrent routine wrote to a key |
| // that matches a key or row-range read inside this batch. (Writes inside a |
| // batch cannot cause that batch's Commit() to fail.) |
| // - Other methods (e.g. Get) will never fail with error ErrConcurrentBatch, |
| // even if it is known that Commit() will fail with this error. |
| // |
| // Concurrency semantics can be configured using BatchOptions. |
| BeginBatch(call rpc.ServerCall, bo BatchOptions) (string, error) |
| // Commit persists the pending changes to the database. |
| // If this Database is not bound to a batch, Commit() will fail with |
| // ErrNotBoundToBatch. |
| Commit(rpc.ServerCall) error |
| // Abort notifies the server that any pending changes can be discarded. |
| // It is not strictly required, but it may allow the server to release locks |
| // or other resources sooner than if it was not called. |
| // If this Database is not bound to a batch, Abort() will fail with |
| // ErrNotBoundToBatch. |
| Abort(rpc.ServerCall) error |
| } |
| |
| // DatabaseServerStubMethods is the server interface containing |
| // Database methods, as expected by rpc.Server. |
| // There is no difference between this interface and DatabaseServerMethods |
| // since there are no streaming methods. |
| type DatabaseServerStubMethods DatabaseServerMethods |
| |
| // DatabaseServerStub adds universal methods to DatabaseServerStubMethods. |
| type DatabaseServerStub interface { |
| DatabaseServerStubMethods |
| // Describe the Database interfaces. |
| Describe__() []rpc.InterfaceDesc |
| } |
| |
| // DatabaseServer returns a server stub for Database. |
| // It converts an implementation of DatabaseServerMethods into |
| // an object that may be used by rpc.Server. |
| func DatabaseServer(impl DatabaseServerMethods) DatabaseServerStub { |
| stub := implDatabaseServerStub{ |
| impl: impl, |
| ObjectServerStub: permissions.ObjectServer(impl), |
| } |
| // Initialize GlobState; always check the stub itself first, to handle the |
| // case where the user has the Glob method defined in their VDL source. |
| if gs := rpc.NewGlobState(stub); gs != nil { |
| stub.gs = gs |
| } else if gs := rpc.NewGlobState(impl); gs != nil { |
| stub.gs = gs |
| } |
| return stub |
| } |
| |
| type implDatabaseServerStub struct { |
| impl DatabaseServerMethods |
| permissions.ObjectServerStub |
| gs *rpc.GlobState |
| } |
| |
| func (s implDatabaseServerStub) CreateTable(call rpc.ServerCall, i0 string, i1 access.Permissions) error { |
| return s.impl.CreateTable(call, i0, i1) |
| } |
| |
| func (s implDatabaseServerStub) DeleteTable(call rpc.ServerCall, i0 string) error { |
| return s.impl.DeleteTable(call, i0) |
| } |
| |
| func (s implDatabaseServerStub) Create(call rpc.ServerCall, i0 access.Permissions) error { |
| return s.impl.Create(call, i0) |
| } |
| |
| func (s implDatabaseServerStub) Delete(call rpc.ServerCall) error { |
| return s.impl.Delete(call) |
| } |
| |
| func (s implDatabaseServerStub) BeginBatch(call rpc.ServerCall, i0 BatchOptions) (string, error) { |
| return s.impl.BeginBatch(call, i0) |
| } |
| |
| func (s implDatabaseServerStub) Commit(call rpc.ServerCall) error { |
| return s.impl.Commit(call) |
| } |
| |
| func (s implDatabaseServerStub) Abort(call rpc.ServerCall) error { |
| return s.impl.Abort(call) |
| } |
| |
| func (s implDatabaseServerStub) Globber() *rpc.GlobState { |
| return s.gs |
| } |
| |
| func (s implDatabaseServerStub) Describe__() []rpc.InterfaceDesc { |
| return []rpc.InterfaceDesc{DatabaseDesc, permissions.ObjectDesc} |
| } |
| |
| // DatabaseDesc describes the Database interface. |
| var DatabaseDesc rpc.InterfaceDesc = descDatabase |
| |
| // descDatabase hides the desc to keep godoc clean. |
| var descDatabase = rpc.InterfaceDesc{ |
| Name: "Database", |
| PkgPath: "v.io/syncbase/v23/services/syncbase/nosql", |
| Doc: "// Database represents a collection of Tables. Batches, queries, sync, watch,\n// etc. all operate at the Database level.\n// Database.Glob operates over Table names.\n//\n// TODO(sadovsky): Add Watch method.", |
| Embeds: []rpc.EmbedDesc{ |
| {"Object", "v.io/v23/services/permissions", "// Object provides access control for Vanadium objects.\n//\n// Vanadium services implementing dynamic access control would typically embed\n// this interface and tag additional methods defined by the service with one of\n// Admin, Read, Write, Resolve etc. For example, the VDL definition of the\n// object would be:\n//\n// package mypackage\n//\n// import \"v.io/v23/security/access\"\n// import \"v.io/v23/services/permissions\"\n//\n// type MyObject interface {\n// permissions.Object\n// MyRead() (string, error) {access.Read}\n// MyWrite(string) error {access.Write}\n// }\n//\n// If the set of pre-defined tags is insufficient, services may define their\n// own tag type and annotate all methods with this new type.\n//\n// Instead of embedding this Object interface, define SetPermissions and\n// GetPermissions in their own interface. Authorization policies will typically\n// respect annotations of a single type. For example, the VDL definition of an\n// object would be:\n//\n// package mypackage\n//\n// import \"v.io/v23/security/access\"\n//\n// type MyTag string\n//\n// const (\n// Blue = MyTag(\"Blue\")\n// Red = MyTag(\"Red\")\n// )\n//\n// type MyObject interface {\n// MyMethod() (string, error) {Blue}\n//\n// // Allow clients to change access via the access.Object interface:\n// SetPermissions(acl access.Permissions, version string) error {Red}\n// GetPermissions() (acl access.Permissions, version string, err error) {Blue}\n// }"}, |
| }, |
| Methods: []rpc.MethodDesc{ |
| { |
| Name: "CreateTable", |
| Doc: "// Create creates the specified Table.\n// If perms is nil, Permissions is inherited (copied) from the Database.\n// relativeName must not contain slashes.", |
| InArgs: []rpc.ArgDesc{ |
| {"relativeName", ``}, // string |
| {"perms", ``}, // access.Permissions |
| }, |
| Tags: []*vdl.Value{vdl.ValueOf(access.Tag("Write"))}, |
| }, |
| { |
| Name: "DeleteTable", |
| Doc: "// DeleteTable deletes the specified Table.", |
| InArgs: []rpc.ArgDesc{ |
| {"relativeName", ``}, // string |
| }, |
| Tags: []*vdl.Value{vdl.ValueOf(access.Tag("Write"))}, |
| }, |
| { |
| Name: "Create", |
| Doc: "// Create creates this Database.\n// If perms is nil, Permissions is inherited (copied) from the App.\n// Create requires the caller to have Write permission at the App.", |
| InArgs: []rpc.ArgDesc{ |
| {"perms", ``}, // access.Permissions |
| }, |
| Tags: []*vdl.Value{vdl.ValueOf(access.Tag("Write"))}, |
| }, |
| { |
| Name: "Delete", |
| Doc: "// Delete deletes this Database.", |
| Tags: []*vdl.Value{vdl.ValueOf(access.Tag("Write"))}, |
| }, |
| { |
| Name: "BeginBatch", |
| Doc: "// BeginBatch creates a new batch. It returns an App-relative name for a\n// Database handle bound to this batch. If this Database is already bound to a\n// batch, BeginBatch() will fail with ErrBoundToBatch.\n//\n// Default concurrency semantics:\n// - Reads inside a batch see a consistent snapshot, taken during\n// BeginBatch(), and will not see the effect of writes inside the batch.\n// - Commit() may fail with ErrConcurrentBatch, indicating that after\n// BeginBatch() but before Commit(), some concurrent routine wrote to a key\n// that matches a key or row-range read inside this batch. (Writes inside a\n// batch cannot cause that batch's Commit() to fail.)\n// - Other methods (e.g. Get) will never fail with error ErrConcurrentBatch,\n// even if it is known that Commit() will fail with this error.\n//\n// Concurrency semantics can be configured using BatchOptions.", |
| InArgs: []rpc.ArgDesc{ |
| {"bo", ``}, // BatchOptions |
| }, |
| OutArgs: []rpc.ArgDesc{ |
| {"", ``}, // string |
| }, |
| Tags: []*vdl.Value{vdl.ValueOf(access.Tag("Read"))}, |
| }, |
| { |
| Name: "Commit", |
| Doc: "// Commit persists the pending changes to the database.\n// If this Database is not bound to a batch, Commit() will fail with\n// ErrNotBoundToBatch.", |
| Tags: []*vdl.Value{vdl.ValueOf(access.Tag("Read"))}, |
| }, |
| { |
| Name: "Abort", |
| Doc: "// Abort notifies the server that any pending changes can be discarded.\n// It is not strictly required, but it may allow the server to release locks\n// or other resources sooner than if it was not called.\n// If this Database is not bound to a batch, Abort() will fail with\n// ErrNotBoundToBatch.", |
| Tags: []*vdl.Value{vdl.ValueOf(access.Tag("Read"))}, |
| }, |
| }, |
| } |
| |
| // TableClientMethods is the client interface |
| // containing Table methods. |
| // |
| // Table represents a collection of Rows. |
| // Table.Glob operates over the primary keys of Rows in the Table. |
| type TableClientMethods interface { |
| // Delete deletes all rows in the given range. See helpers nosql.Prefix(), |
| // nosql.Range(), nosql.SingleRow(). If the last row that is covered by a |
| // prefix from SetPermissions is deleted, that (prefix, permissions) pair is |
| // removed. |
| // TODO(sadovsky): Automatic GC does not interact well with sync, especially |
| // in the presence of fine-grained ACLs. Need to think this through. Perhaps |
| // we should only remove prefix permissions fully covered by the given |
| // RowRange. |
| Delete(ctx *context.T, start string, limit string, opts ...rpc.CallOpt) error |
| // SetPermissions sets the permissions for all current and future rows with |
| // the given prefix. If the prefix overlaps with an existing prefix, the |
| // longest prefix that matches a row applies. For example: |
| // SetPermissions(ctx, Prefix("a/b"), perms1) |
| // SetPermissions(ctx, Prefix("a/b/c"), perms2) |
| // The permissions for row "a/b/1" are perms1, and the permissions for row |
| // "a/b/c/1" are perms2. |
| // |
| // SetPermissions will fail if called with a prefix that does not match any |
| // rows. |
| SetPermissions(ctx *context.T, prefix string, perms access.Permissions, opts ...rpc.CallOpt) error |
| // GetPermissions returns an array of (prefix, permissions) pairs. The array |
| // is sorted from longest prefix to shortest, so element zero is the one that |
| // applies to the row with the given key. The last element is always the |
| // prefix "" which represents the table's permissions -- the array will always |
| // have at least one element. |
| GetPermissions(ctx *context.T, key string, opts ...rpc.CallOpt) ([]PrefixPermissions, error) |
| // DeletePermissions deletes the permissions for the specified prefix. Any |
| // rows covered by this prefix will use the next longest prefix's permissions |
| // (see the array returned by GetPermissions). |
| DeletePermissions(ctx *context.T, prefix string, opts ...rpc.CallOpt) error |
| } |
| |
| // TableClientStub adds universal methods to TableClientMethods. |
| type TableClientStub interface { |
| TableClientMethods |
| rpc.UniversalServiceMethods |
| } |
| |
| // TableClient returns a client stub for Table. |
| func TableClient(name string) TableClientStub { |
| return implTableClientStub{name} |
| } |
| |
| type implTableClientStub struct { |
| name string |
| } |
| |
| func (c implTableClientStub) Delete(ctx *context.T, i0 string, i1 string, opts ...rpc.CallOpt) (err error) { |
| err = v23.GetClient(ctx).Call(ctx, c.name, "Delete", []interface{}{i0, i1}, nil, opts...) |
| return |
| } |
| |
| func (c implTableClientStub) SetPermissions(ctx *context.T, i0 string, i1 access.Permissions, opts ...rpc.CallOpt) (err error) { |
| err = v23.GetClient(ctx).Call(ctx, c.name, "SetPermissions", []interface{}{i0, i1}, nil, opts...) |
| return |
| } |
| |
| func (c implTableClientStub) GetPermissions(ctx *context.T, i0 string, opts ...rpc.CallOpt) (o0 []PrefixPermissions, err error) { |
| err = v23.GetClient(ctx).Call(ctx, c.name, "GetPermissions", []interface{}{i0}, []interface{}{&o0}, opts...) |
| return |
| } |
| |
| func (c implTableClientStub) DeletePermissions(ctx *context.T, i0 string, opts ...rpc.CallOpt) (err error) { |
| err = v23.GetClient(ctx).Call(ctx, c.name, "DeletePermissions", []interface{}{i0}, nil, opts...) |
| return |
| } |
| |
| // TableServerMethods is the interface a server writer |
| // implements for Table. |
| // |
| // Table represents a collection of Rows. |
| // Table.Glob operates over the primary keys of Rows in the Table. |
| type TableServerMethods interface { |
| // Delete deletes all rows in the given range. See helpers nosql.Prefix(), |
| // nosql.Range(), nosql.SingleRow(). If the last row that is covered by a |
| // prefix from SetPermissions is deleted, that (prefix, permissions) pair is |
| // removed. |
| // TODO(sadovsky): Automatic GC does not interact well with sync, especially |
| // in the presence of fine-grained ACLs. Need to think this through. Perhaps |
| // we should only remove prefix permissions fully covered by the given |
| // RowRange. |
| Delete(call rpc.ServerCall, start string, limit string) error |
| // SetPermissions sets the permissions for all current and future rows with |
| // the given prefix. If the prefix overlaps with an existing prefix, the |
| // longest prefix that matches a row applies. For example: |
| // SetPermissions(ctx, Prefix("a/b"), perms1) |
| // SetPermissions(ctx, Prefix("a/b/c"), perms2) |
| // The permissions for row "a/b/1" are perms1, and the permissions for row |
| // "a/b/c/1" are perms2. |
| // |
| // SetPermissions will fail if called with a prefix that does not match any |
| // rows. |
| SetPermissions(call rpc.ServerCall, prefix string, perms access.Permissions) error |
| // GetPermissions returns an array of (prefix, permissions) pairs. The array |
| // is sorted from longest prefix to shortest, so element zero is the one that |
| // applies to the row with the given key. The last element is always the |
| // prefix "" which represents the table's permissions -- the array will always |
| // have at least one element. |
| GetPermissions(call rpc.ServerCall, key string) ([]PrefixPermissions, error) |
| // DeletePermissions deletes the permissions for the specified prefix. Any |
| // rows covered by this prefix will use the next longest prefix's permissions |
| // (see the array returned by GetPermissions). |
| DeletePermissions(call rpc.ServerCall, prefix string) error |
| } |
| |
| // TableServerStubMethods is the server interface containing |
| // Table methods, as expected by rpc.Server. |
| // There is no difference between this interface and TableServerMethods |
| // since there are no streaming methods. |
| type TableServerStubMethods TableServerMethods |
| |
| // TableServerStub adds universal methods to TableServerStubMethods. |
| type TableServerStub interface { |
| TableServerStubMethods |
| // Describe the Table interfaces. |
| Describe__() []rpc.InterfaceDesc |
| } |
| |
| // TableServer returns a server stub for Table. |
| // It converts an implementation of TableServerMethods into |
| // an object that may be used by rpc.Server. |
| func TableServer(impl TableServerMethods) TableServerStub { |
| stub := implTableServerStub{ |
| impl: impl, |
| } |
| // Initialize GlobState; always check the stub itself first, to handle the |
| // case where the user has the Glob method defined in their VDL source. |
| if gs := rpc.NewGlobState(stub); gs != nil { |
| stub.gs = gs |
| } else if gs := rpc.NewGlobState(impl); gs != nil { |
| stub.gs = gs |
| } |
| return stub |
| } |
| |
| type implTableServerStub struct { |
| impl TableServerMethods |
| gs *rpc.GlobState |
| } |
| |
| func (s implTableServerStub) Delete(call rpc.ServerCall, i0 string, i1 string) error { |
| return s.impl.Delete(call, i0, i1) |
| } |
| |
| func (s implTableServerStub) SetPermissions(call rpc.ServerCall, i0 string, i1 access.Permissions) error { |
| return s.impl.SetPermissions(call, i0, i1) |
| } |
| |
| func (s implTableServerStub) GetPermissions(call rpc.ServerCall, i0 string) ([]PrefixPermissions, error) { |
| return s.impl.GetPermissions(call, i0) |
| } |
| |
| func (s implTableServerStub) DeletePermissions(call rpc.ServerCall, i0 string) error { |
| return s.impl.DeletePermissions(call, i0) |
| } |
| |
| func (s implTableServerStub) Globber() *rpc.GlobState { |
| return s.gs |
| } |
| |
| func (s implTableServerStub) Describe__() []rpc.InterfaceDesc { |
| return []rpc.InterfaceDesc{TableDesc} |
| } |
| |
| // TableDesc describes the Table interface. |
| var TableDesc rpc.InterfaceDesc = descTable |
| |
| // descTable hides the desc to keep godoc clean. |
| var descTable = rpc.InterfaceDesc{ |
| Name: "Table", |
| PkgPath: "v.io/syncbase/v23/services/syncbase/nosql", |
| Doc: "// Table represents a collection of Rows.\n// Table.Glob operates over the primary keys of Rows in the Table.", |
| Methods: []rpc.MethodDesc{ |
| { |
| Name: "Delete", |
| Doc: "// Delete deletes all rows in the given range. See helpers nosql.Prefix(),\n// nosql.Range(), nosql.SingleRow(). If the last row that is covered by a\n// prefix from SetPermissions is deleted, that (prefix, permissions) pair is\n// removed.\n// TODO(sadovsky): Automatic GC does not interact well with sync, especially\n// in the presence of fine-grained ACLs. Need to think this through. Perhaps\n// we should only remove prefix permissions fully covered by the given\n// RowRange.", |
| InArgs: []rpc.ArgDesc{ |
| {"start", ``}, // string |
| {"limit", ``}, // string |
| }, |
| }, |
| { |
| Name: "SetPermissions", |
| Doc: "// SetPermissions sets the permissions for all current and future rows with\n// the given prefix. If the prefix overlaps with an existing prefix, the\n// longest prefix that matches a row applies. For example:\n// SetPermissions(ctx, Prefix(\"a/b\"), perms1)\n// SetPermissions(ctx, Prefix(\"a/b/c\"), perms2)\n// The permissions for row \"a/b/1\" are perms1, and the permissions for row\n// \"a/b/c/1\" are perms2.\n//\n// SetPermissions will fail if called with a prefix that does not match any\n// rows.", |
| InArgs: []rpc.ArgDesc{ |
| {"prefix", ``}, // string |
| {"perms", ``}, // access.Permissions |
| }, |
| Tags: []*vdl.Value{vdl.ValueOf(access.Tag("Admin"))}, |
| }, |
| { |
| Name: "GetPermissions", |
| Doc: "// GetPermissions returns an array of (prefix, permissions) pairs. The array\n// is sorted from longest prefix to shortest, so element zero is the one that\n// applies to the row with the given key. The last element is always the\n// prefix \"\" which represents the table's permissions -- the array will always\n// have at least one element.", |
| InArgs: []rpc.ArgDesc{ |
| {"key", ``}, // string |
| }, |
| OutArgs: []rpc.ArgDesc{ |
| {"", ``}, // []PrefixPermissions |
| }, |
| Tags: []*vdl.Value{vdl.ValueOf(access.Tag("Admin"))}, |
| }, |
| { |
| Name: "DeletePermissions", |
| Doc: "// DeletePermissions deletes the permissions for the specified prefix. Any\n// rows covered by this prefix will use the next longest prefix's permissions\n// (see the array returned by GetPermissions).", |
| InArgs: []rpc.ArgDesc{ |
| {"prefix", ``}, // string |
| }, |
| Tags: []*vdl.Value{vdl.ValueOf(access.Tag("Admin"))}, |
| }, |
| }, |
| } |
| |
| // RowClientMethods is the client interface |
| // containing Row methods. |
| // |
| // Row represents a single row in a Table. |
| // All access checks are performed against the most specific matching prefix |
| // permissions in the Table. |
| type RowClientMethods interface { |
| // Get returns the value for this Row. |
| Get(*context.T, ...rpc.CallOpt) (*vdl.Value, error) |
| // Put writes the given value for this Row. |
| Put(ctx *context.T, value *vdl.Value, opts ...rpc.CallOpt) error |
| // Delete deletes this Row. |
| Delete(*context.T, ...rpc.CallOpt) error |
| } |
| |
| // RowClientStub adds universal methods to RowClientMethods. |
| type RowClientStub interface { |
| RowClientMethods |
| rpc.UniversalServiceMethods |
| } |
| |
| // RowClient returns a client stub for Row. |
| func RowClient(name string) RowClientStub { |
| return implRowClientStub{name} |
| } |
| |
| type implRowClientStub struct { |
| name string |
| } |
| |
| func (c implRowClientStub) Get(ctx *context.T, opts ...rpc.CallOpt) (o0 *vdl.Value, err error) { |
| err = v23.GetClient(ctx).Call(ctx, c.name, "Get", nil, []interface{}{&o0}, opts...) |
| return |
| } |
| |
| func (c implRowClientStub) Put(ctx *context.T, i0 *vdl.Value, opts ...rpc.CallOpt) (err error) { |
| err = v23.GetClient(ctx).Call(ctx, c.name, "Put", []interface{}{i0}, nil, opts...) |
| return |
| } |
| |
| func (c implRowClientStub) Delete(ctx *context.T, opts ...rpc.CallOpt) (err error) { |
| err = v23.GetClient(ctx).Call(ctx, c.name, "Delete", nil, nil, opts...) |
| return |
| } |
| |
| // RowServerMethods is the interface a server writer |
| // implements for Row. |
| // |
| // Row represents a single row in a Table. |
| // All access checks are performed against the most specific matching prefix |
| // permissions in the Table. |
| type RowServerMethods interface { |
| // Get returns the value for this Row. |
| Get(rpc.ServerCall) (*vdl.Value, error) |
| // Put writes the given value for this Row. |
| Put(call rpc.ServerCall, value *vdl.Value) error |
| // Delete deletes this Row. |
| Delete(rpc.ServerCall) error |
| } |
| |
| // RowServerStubMethods is the server interface containing |
| // Row methods, as expected by rpc.Server. |
| // There is no difference between this interface and RowServerMethods |
| // since there are no streaming methods. |
| type RowServerStubMethods RowServerMethods |
| |
| // RowServerStub adds universal methods to RowServerStubMethods. |
| type RowServerStub interface { |
| RowServerStubMethods |
| // Describe the Row interfaces. |
| Describe__() []rpc.InterfaceDesc |
| } |
| |
| // RowServer returns a server stub for Row. |
| // It converts an implementation of RowServerMethods into |
| // an object that may be used by rpc.Server. |
| func RowServer(impl RowServerMethods) RowServerStub { |
| stub := implRowServerStub{ |
| impl: impl, |
| } |
| // Initialize GlobState; always check the stub itself first, to handle the |
| // case where the user has the Glob method defined in their VDL source. |
| if gs := rpc.NewGlobState(stub); gs != nil { |
| stub.gs = gs |
| } else if gs := rpc.NewGlobState(impl); gs != nil { |
| stub.gs = gs |
| } |
| return stub |
| } |
| |
| type implRowServerStub struct { |
| impl RowServerMethods |
| gs *rpc.GlobState |
| } |
| |
| func (s implRowServerStub) Get(call rpc.ServerCall) (*vdl.Value, error) { |
| return s.impl.Get(call) |
| } |
| |
| func (s implRowServerStub) Put(call rpc.ServerCall, i0 *vdl.Value) error { |
| return s.impl.Put(call, i0) |
| } |
| |
| func (s implRowServerStub) Delete(call rpc.ServerCall) error { |
| return s.impl.Delete(call) |
| } |
| |
| func (s implRowServerStub) Globber() *rpc.GlobState { |
| return s.gs |
| } |
| |
| func (s implRowServerStub) Describe__() []rpc.InterfaceDesc { |
| return []rpc.InterfaceDesc{RowDesc} |
| } |
| |
| // RowDesc describes the Row interface. |
| var RowDesc rpc.InterfaceDesc = descRow |
| |
| // descRow hides the desc to keep godoc clean. |
| var descRow = rpc.InterfaceDesc{ |
| Name: "Row", |
| PkgPath: "v.io/syncbase/v23/services/syncbase/nosql", |
| Doc: "// Row represents a single row in a Table.\n// All access checks are performed against the most specific matching prefix\n// permissions in the Table.", |
| Methods: []rpc.MethodDesc{ |
| { |
| Name: "Get", |
| Doc: "// Get returns the value for this Row.", |
| OutArgs: []rpc.ArgDesc{ |
| {"", ``}, // *vdl.Value |
| }, |
| Tags: []*vdl.Value{vdl.ValueOf(access.Tag("Read"))}, |
| }, |
| { |
| Name: "Put", |
| Doc: "// Put writes the given value for this Row.", |
| InArgs: []rpc.ArgDesc{ |
| {"value", ``}, // *vdl.Value |
| }, |
| Tags: []*vdl.Value{vdl.ValueOf(access.Tag("Write"))}, |
| }, |
| { |
| Name: "Delete", |
| Doc: "// Delete deletes this Row.", |
| Tags: []*vdl.Value{vdl.ValueOf(access.Tag("Write"))}, |
| }, |
| }, |
| } |