blob: 5d5dd4ebfbbae3ed570ecfaca06a8624cd789d94 [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.
// Package syncbase defines the wire API for a structured store that supports
// peer-to-peer synchronization.
//
// TODO(sadovsky): Write a detailed package description, or provide a reference
// to the Syncbase documentation.
package syncbase
import (
"time"
"v.io/v23/security/access"
"v.io/v23/services/permissions"
)
// NOTE(sadovsky): Various methods below may end up needing additional options.
// TODO(sadovsky): Move "DevMode" methods elsewhere, so that they are completely
// hidden from clients. Relatedly, configure the server to not even export these
// RPC methods if the --dev flag is not set.
// Service represents a Vanadium Syncbase service.
// Service.Glob operates over App names.
type Service interface {
// DevModeUpdateVClock updates various bits of Syncbase virtual clock and clock
// daemon state based on the specified options.
// Requires --dev flag to be set (in addition to Admin check).
DevModeUpdateVClock(uco DevModeUpdateVClockOpts) error {access.Admin}
// DevModeGetTime returns the current time per the Syncbase clock.
// Requires --dev flag to be set (in addition to Admin check).
DevModeGetTime() (time.Time | error) {access.Admin}
// SetPermissions and GetPermissions are included from the Object interface.
permissions.Object
}
// App represents the data for a specific app instance (possibly a combination
// of user, device, and app).
// App.Glob operates over Database names.
type App interface {
// Create creates this App.
// If perms is nil, we inherit (copy) the Service perms.
// Create requires the caller to have Write permission at the Service.
Create(perms access.Permissions) error {access.Write}
// Destroy destroys this App.
Destroy() error {access.Write}
// Exists returns true only if this App exists. Insufficient permissions
// cause Exists to return false instead of an error.
Exists() (bool | error) {access.Resolve}
// SetPermissions and GetPermissions are included from the Object interface.
permissions.Object
}
error (
NotInDevMode() {"en": "not running with --dev=true"}
InvalidName(name string) {"en": "invalid name: {name}"}
CorruptDatabase(path string) {"en": "database corrupt, moved to {path}; client must create a new database"}
UnknownBatch() {"en": "unknown batch, perhaps the server restarted"}
)