blob: 359e252a0f41eeb63885645cf8104a6c24b41cd6 [file] [log] [blame]
// 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.
// TODO(sadovsky): Copy struct and interface comments from VDL files.
// TODO(sadovsky): This should probably be something else.
module mojo;
// TODO(sadovsky): Put structs in a separate types.mojom file.
// TODO(sadovsky): Loose representation of verror. Improve this.
struct Error {
string id; // empty string means no error
uint32 action_code;
string msg;
};
// TODO(sadovsky): Decide how to represent perms.
struct Perms {
string json;
};
struct BatchOptions {
string hint;
bool read_only;
};
struct PrefixPerms {
string prefix;
Perms perms;
};
struct TableRow {
string table_name;
string row;
};
struct SyncgroupSpec {
string description;
Perms perms;
array<TableRow> prefixes;
array<string> mount_tables;
bool is_private;
};
struct SyncgroupMemberInfo {
uint8 sync_priority;
};
struct Result {
array<array<uint8>> values;
};
// In this model, the server pushes one stream item to the client, then waits
// for an ack from the client before sending the next item, thus providing
// flow control.
[ServiceName="v23::syncbase::ExecStream"]
interface ExecStream {
OnResult(Result result) => ();
OnDone(Error err);
};
struct KeyValue {
string key;
array<uint8> value;
};
// In this model, the server pushes one stream item to the client, then waits
// for an ack from the client before sending the next item, thus providing
// flow control.
[ServiceName="v23::syncbase::ScanStream"]
interface ScanStream {
OnKeyValue(KeyValue key_value) => ();
OnDone(Error err);
};
struct WatchChange {
string table_name;
string row_key;
uint32 change_type;
array<uint8> value_bytes;
array<uint8> resume_marker;
bool from_sync;
bool continued;
};
struct GlobRequest {
string pattern;
array<uint8> resume_marker;
};
// In this model, the server pushes one stream item to the client, then waits
// for an ack from the client before sending the next item, thus providing
// flow control.
[ServiceName="v23::syncbase::WatchGlobStream"]
interface WatchGlobStream {
OnChange(WatchChange change) => ();
OnError(Error err);
};
// TODO(sadovsky): Add schema version to all RPCs. See v.io/c/13734.
// All 'name' params are service-relative object names.
// Error handling modeled after:
// https://github.com/domokit/mojo/blob/master/mojo/services/files/public/interfaces/file.mojom
[ServiceName="v23::syncbase::Syncbase"]
interface Syncbase {
////////////////////////////////////////
// Service
ServiceGetPermissions() => (Error err, Perms perms, string version);
ServiceSetPermissions(Perms perms, string version) => (Error err);
ServiceListApps() => (Error err, array<string> apps);
////////////////////////////////////////
// App
AppCreate(string name, Perms perms) => (Error err);
AppDestroy(string name) => (Error err);
AppExists(string name) => (Error err, bool exists);
AppGetPermissions(string name) => (Error err, Perms perms, string version);
AppListDatabases(string name) => (Error err, array<string> databases);
AppSetPermissions(string name, Perms perms, string version) => (Error err);
////////////////////////////////////////
// nosql.Database
// TODO(sadovsky): Add SchemaMetadata argument.
DbCreate(string name, Perms perms) => (Error err);
DbDestroy(string name) => (Error err);
DbExists(string name) => (Error err, bool exists);
DbExec(string name, string query, array<array<uint8>> parameters, ExecStream stream) => (Error err);
DbBeginBatch(string name, BatchOptions? bo) => (Error err, string batch_suffix);
DbCommit(string name) => (Error err);
DbAbort(string name) => (Error err);
DbGetPermissions(string name) => (Error err, Perms perms, string version);
DbSetPermissions(string name, Perms perms, string version) => (Error err);
DbWatchGlob(string name, GlobRequest req, WatchGlobStream stream) => (Error err);
DbGetResumeMarker(string name) => (Error err, array<uint8> resumeMarker);
DbListTables(string name) => (Error err, array<string> tables);
// TODO(sadovsky): Add DatabaseWatcher, BlobManager, and SchemaManager
// methods.
////////////////////////////////////////
// nosql.Database:SyncgroupManager
DbGetSyncgroupNames(string name) => (Error err, array<string> names);
DbCreateSyncgroup(
string name, string sg_name, SyncgroupSpec spec,
SyncgroupMemberInfo my_info)
=> (Error err);
DbJoinSyncgroup(string name, string sg_name, SyncgroupMemberInfo my_info)
=> (Error err, SyncgroupSpec spec);
DbLeaveSyncgroup(string name, string sg_name) => (Error err);
DbDestroySyncgroup(string name, string sg_name) => (Error err);
DbEjectFromSyncgroup(string name, string sg_name, string member)
=> (Error err);
DbGetSyncgroupSpec(string name, string sg_name)
=> (Error err, SyncgroupSpec spec, string version);
DbSetSyncgroupSpec(
string name, string sg_name, SyncgroupSpec spec, string version)
=> (Error err);
DbGetSyncgroupMembers(string name, string sg_name)
=> (Error err, map<string, SyncgroupMemberInfo> infos);
////////////////////////////////////////
// nosql.Table
TableCreate(string name, Perms perms) => (Error err);
TableDestroy(string name) => (Error err);
TableExists(string name) => (Error err, bool exists);
TableGetPermissions(string name) => (Error err, Perms perms);
TableSetPermissions(string name, Perms perms) => (Error err);
TableDeleteRange(string name, array<uint8> start, array<uint8> limit)
=> (Error err);
TableScan(
string name, array<uint8> start, array<uint8> limit, ScanStream stream)
=> (Error err);
TableGetPrefixPermissions(string name, string key)
=> (Error err, array<PrefixPerms> perms_arr);
TableSetPrefixPermissions(string name, string prefix, Perms perms) => (Error err);
TableDeletePrefixPermissions(string name, string prefix) => (Error err);
////////////////////////////////////////
// nosql.Row
RowExists(string name) => (Error err, bool exists);
RowGet(string name) => (Error err, array<uint8> value);
RowPut(string name, array<uint8> value) => (Error err);
RowDelete(string name) => (Error err);
};