interfaces

package
v0.0.0-...-ba1c585 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 29, 2017 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Overview

Package interfaces defines internal interfaces for various objects in the Syncbase server implementation. Defining these interfaces in a separate package helps prevent import cycles: all other packages can import the interfaces package, and individual modules can pass each other interfaces to enable bidirectional cross-package communication.

Index

Constants

View Source
const LinkRec = byte(1)

LinkRec type log record adds a new link in the dag. Link records are added when a conflict is resolved by picking the local or the remote version as the resolution of a conflict, instead of creating a new version.

View Source
const NoGroupId = GroupId("")
View Source
const NodeRec = byte(0)

NodeRec type log record adds a new node in the dag.

Variables

View Source
var (
	ErrDupSyncgroupPublish = verror.Register("v.io/x/ref/services/syncbase/server/interfaces.DupSyncgroupPublish", verror.NoRetry, "{1:}{2:} duplicate publish on syncgroup: {3}")
	ErrConnFail            = verror.Register("v.io/x/ref/services/syncbase/server/interfaces.ConnFail", verror.NoRetry, "{1:}{2:} connection to peer failed{:_}")
	ErrBrokenCrConnection  = verror.Register("v.io/x/ref/services/syncbase/server/interfaces.BrokenCrConnection", verror.NoRetry, "{1:}{2:} CrConnection stream to client does not exist or is broken")
	ErrDbOffline           = verror.Register("v.io/x/ref/services/syncbase/server/interfaces.DbOffline", verror.NoRetry, "{1:}{2:} database {3} is offline and cannot be synced{:_}")
	ErrGetTimeFailed       = verror.Register("v.io/x/ref/services/syncbase/server/interfaces.GetTimeFailed", verror.NoRetry, "{1:}{2:} GetTime failed{:_}")
	ErrNotAdmin            = verror.Register("v.io/x/ref/services/syncbase/server/interfaces.NotAdmin", verror.NoRetry, "{1:}{2:} not an admin of the syncgroup")
)
View Source
var SyncDesc rpc.InterfaceDesc = descSync

SyncDesc describes the Sync interface.

SyncgroupStatusAll holds all labels for SyncgroupStatus.

Functions

func NewErrBrokenCrConnection

func NewErrBrokenCrConnection(ctx *context.T) error

NewErrBrokenCrConnection returns an error with the ErrBrokenCrConnection ID.

func NewErrConnFail

func NewErrConnFail(ctx *context.T) error

NewErrConnFail returns an error with the ErrConnFail ID.

func NewErrDbOffline

func NewErrDbOffline(ctx *context.T, dbId syncbase.Id) error

NewErrDbOffline returns an error with the ErrDbOffline ID.

func NewErrDupSyncgroupPublish

func NewErrDupSyncgroupPublish(ctx *context.T, sgId syncbase.Id) error

NewErrDupSyncgroupPublish returns an error with the ErrDupSyncgroupPublish ID.

func NewErrGetTimeFailed

func NewErrGetTimeFailed(ctx *context.T) error

NewErrGetTimeFailed returns an error with the ErrGetTimeFailed ID.

func NewErrNotAdmin

func NewErrNotAdmin(ctx *context.T) error

NewErrNotAdmin returns an error with the ErrNotAdmin ID.

func VDLReadDeltaReq

func VDLReadDeltaReq(dec vdl.Decoder, x *DeltaReq) error

func VDLReadDeltaResp

func VDLReadDeltaResp(dec vdl.Decoder, x *DeltaResp) error

Types

type BlobSharesBySyncgroup

type BlobSharesBySyncgroup map[GroupId]int32

A BlobSharesBySyncgroup maps syncgroup IDs to integer share numbers that a syncbase instance may have for a blob.

func (BlobSharesBySyncgroup) VDLIsZero

func (x BlobSharesBySyncgroup) VDLIsZero() bool

func (*BlobSharesBySyncgroup) VDLRead

func (x *BlobSharesBySyncgroup) VDLRead(dec vdl.Decoder) error

func (BlobSharesBySyncgroup) VDLReflect

func (BlobSharesBySyncgroup) VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/services/syncbase/server/interfaces.BlobSharesBySyncgroup"`
})

func (BlobSharesBySyncgroup) VDLWrite

func (x BlobSharesBySyncgroup) VDLWrite(enc vdl.Encoder) error

type ChunkData

type ChunkData struct {
	Data []byte
}

ChunkData contains the data of a chunk.

func (ChunkData) VDLIsZero

func (x ChunkData) VDLIsZero() bool

func (*ChunkData) VDLRead

func (x *ChunkData) VDLRead(dec vdl.Decoder) error

func (ChunkData) VDLReflect

func (ChunkData) VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/services/syncbase/server/interfaces.ChunkData"`
})

func (ChunkData) VDLWrite

func (x ChunkData) VDLWrite(enc vdl.Encoder) error

type ChunkHash

type ChunkHash struct {
	Hash []byte
}

ChunkHash contains the hash of a chunk that is part of a blob's recipe.

func (ChunkHash) VDLIsZero

func (x ChunkHash) VDLIsZero() bool

func (*ChunkHash) VDLRead

func (x *ChunkHash) VDLRead(dec vdl.Decoder) error

func (ChunkHash) VDLReflect

func (ChunkHash) VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/services/syncbase/server/interfaces.ChunkHash"`
})

func (ChunkHash) VDLWrite

func (x ChunkHash) VDLWrite(enc vdl.Encoder) error

type CollectionPerms

type CollectionPerms access.Permissions

CollectionPerms represent the persistent, synced permissions of a Collection. Existence of CollectionPerms in the store determines existence of the Collection. Note: Since CollectionPerms is synced and conflict resolved, the sync protocol needs to be aware of it. Any potential additions to synced Collection metadata should be written to a separate, synced key prefix, written in the same transaction with CollectionPerms and incorporated into the sync protocol. All persistent Collection metadata should be synced; local-only metadata is acceptable only if optional (e.g. stats).

func (*CollectionPerms) GetPerms

func (perms *CollectionPerms) GetPerms() access.Permissions

func (CollectionPerms) VDLIsZero

func (x CollectionPerms) VDLIsZero() bool

func (*CollectionPerms) VDLRead

func (x *CollectionPerms) VDLRead(dec vdl.Decoder) error

func (CollectionPerms) VDLReflect

func (CollectionPerms) VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/services/syncbase/server/interfaces.CollectionPerms"`
})

func (CollectionPerms) VDLWrite

func (x CollectionPerms) VDLWrite(enc vdl.Encoder) error

type DataDeltaReq

type DataDeltaReq struct {
	DbId  syncbase.Id
	SgIds map[GroupId]struct{}
	Gvs   Knowledge
}

DataDeltaReq contains the initiator's genvectors and the set of syncgroups it is interested in within a database when requesting deltas for that database.

func (DataDeltaReq) VDLIsZero

func (x DataDeltaReq) VDLIsZero() bool

func (*DataDeltaReq) VDLRead

func (x *DataDeltaReq) VDLRead(dec vdl.Decoder) error

func (DataDeltaReq) VDLReflect

func (DataDeltaReq) VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/services/syncbase/server/interfaces.DataDeltaReq"`
})

func (DataDeltaReq) VDLWrite

func (x DataDeltaReq) VDLWrite(enc vdl.Encoder) error

type Database

type Database interface {
	// Id returns the id of this database.
	Id() wire.Id

	// St returns the storage engine instance for this database.
	St() *watchable.Store

	// CheckExists returns an error if this database does not exist, transformed
	// to prevent leaking existence information if the client has no access to it.
	CheckExists(ctx *context.T, call rpc.ServerCall) error

	// Service returns the service handle for this database.
	Service() Service

	// GetCollectionPerms retrieves the permissions for the Collection with the
	// given id. No authorization check is performed.
	GetCollectionPerms(ctx *context.T, cxId wire.Id, st store.StoreReader) (access.Permissions, error)

	// GetSchemaMetadataInternal returns SchemaMetadata stored for this db
	// without checking any credentials.
	GetSchemaMetadataInternal(ctx *context.T) (*wire.SchemaMetadata, error)

	// CrConnectionStream returns the current conflict resolution stream
	// established between an app and this database.
	CrConnectionStream() wire.ConflictManagerStartConflictResolverServerStream

	// ResetCrConnectionStream resets the current conflict resolution stream.
	// This can be used to either close an active stream or to remove a dead
	// stream.
	// Note: Resetting a stream does not reconnect the stream. Its upto the
	// client to reconnect.
	ResetCrConnectionStream()

	common.Permser
}

Database is an internal interface to the database layer.

type DeltaFinalResp

type DeltaFinalResp struct {
	SgPriorities SgPriorities
}

DeltaFinalResp contains the data returned at the end of a GetDeltas call.

func (DeltaFinalResp) VDLIsZero

func (x DeltaFinalResp) VDLIsZero() bool

func (*DeltaFinalResp) VDLRead

func (x *DeltaFinalResp) VDLRead(dec vdl.Decoder) error

func (DeltaFinalResp) VDLReflect

func (DeltaFinalResp) VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/services/syncbase/server/interfaces.DeltaFinalResp"`
})

func (DeltaFinalResp) VDLWrite

func (x DeltaFinalResp) VDLWrite(enc vdl.Encoder) error

type DeltaReq

type DeltaReq interface {
	// Index returns the field index.
	Index() int
	// Interface returns the field value as an interface.
	Interface() interface{}
	// Name returns the field name.
	Name() string
	// VDLReflect describes the DeltaReq union type.
	VDLReflect(__DeltaReqReflect)
	VDLIsZero() bool
	VDLWrite(vdl.Encoder) error
}

DeltaReq represents any single field of the DeltaReq union type.

DeltaReq contains a request to sync either data or syncgroup metadata for a Database.

type DeltaReqData

type DeltaReqData struct{ Value DataDeltaReq }

DeltaReqData represents field Data of the DeltaReq union type.

func (DeltaReqData) Index

func (x DeltaReqData) Index() int

func (DeltaReqData) Interface

func (x DeltaReqData) Interface() interface{}

func (DeltaReqData) Name

func (x DeltaReqData) Name() string

func (DeltaReqData) VDLIsZero

func (x DeltaReqData) VDLIsZero() bool

func (DeltaReqData) VDLReflect

func (x DeltaReqData) VDLReflect(__DeltaReqReflect)

func (DeltaReqData) VDLWrite

func (x DeltaReqData) VDLWrite(enc vdl.Encoder) error

type DeltaReqSgs

type DeltaReqSgs struct{ Value SgDeltaReq }

DeltaReqSgs represents field Sgs of the DeltaReq union type.

func (DeltaReqSgs) Index

func (x DeltaReqSgs) Index() int

func (DeltaReqSgs) Interface

func (x DeltaReqSgs) Interface() interface{}

func (DeltaReqSgs) Name

func (x DeltaReqSgs) Name() string

func (DeltaReqSgs) VDLIsZero

func (x DeltaReqSgs) VDLIsZero() bool

func (DeltaReqSgs) VDLReflect

func (x DeltaReqSgs) VDLReflect(__DeltaReqReflect)

func (DeltaReqSgs) VDLWrite

func (x DeltaReqSgs) VDLWrite(enc vdl.Encoder) error

type DeltaResp

type DeltaResp interface {
	// Index returns the field index.
	Index() int
	// Interface returns the field value as an interface.
	Interface() interface{}
	// Name returns the field name.
	Name() string
	// VDLReflect describes the DeltaResp union type.
	VDLReflect(__DeltaRespReflect)
	VDLIsZero() bool
	VDLWrite(vdl.Encoder) error
}

DeltaResp represents any single field of the DeltaResp union type.

DeltaResp contains the responder's genvectors or the missing log records returned in response to an initiator's request for deltas for a Database.

type DeltaRespGvs

type DeltaRespGvs struct{ Value Knowledge }

DeltaRespGvs represents field Gvs of the DeltaResp union type.

func (DeltaRespGvs) Index

func (x DeltaRespGvs) Index() int

func (DeltaRespGvs) Interface

func (x DeltaRespGvs) Interface() interface{}

func (DeltaRespGvs) Name

func (x DeltaRespGvs) Name() string

func (DeltaRespGvs) VDLIsZero

func (x DeltaRespGvs) VDLIsZero() bool

func (DeltaRespGvs) VDLReflect

func (x DeltaRespGvs) VDLReflect(__DeltaRespReflect)

func (DeltaRespGvs) VDLWrite

func (x DeltaRespGvs) VDLWrite(enc vdl.Encoder) error

type DeltaRespRec

type DeltaRespRec struct{ Value LogRec }

DeltaRespRec represents field Rec of the DeltaResp union type.

func (DeltaRespRec) Index

func (x DeltaRespRec) Index() int

func (DeltaRespRec) Interface

func (x DeltaRespRec) Interface() interface{}

func (DeltaRespRec) Name

func (x DeltaRespRec) Name() string

func (DeltaRespRec) VDLIsZero

func (x DeltaRespRec) VDLIsZero() bool

func (DeltaRespRec) VDLReflect

func (x DeltaRespRec) VDLReflect(__DeltaRespReflect)

func (DeltaRespRec) VDLWrite

func (x DeltaRespRec) VDLWrite(enc vdl.Encoder) error

type GenVector

type GenVector map[uint64]uint64

GenVector is the generation vector for any syncable entity, which maps each device id to its last locally known generation in the scope of that entity.

func (GenVector) Compare

func (a GenVector) Compare(b GenVector) int

Compare returns an integer comparing two generation vectors. The result will be 0 if a==b, -1 if a < b, +1 if a > b and +2 if a and b are uncomparable.

func (GenVector) DeepCopy

func (in GenVector) DeepCopy() GenVector

func (GenVector) VDLIsZero

func (x GenVector) VDLIsZero() bool

func (*GenVector) VDLRead

func (x *GenVector) VDLRead(dec vdl.Decoder) error

func (GenVector) VDLReflect

func (GenVector) VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/services/syncbase/server/interfaces.GenVector"`
})

func (GenVector) VDLWrite

func (x GenVector) VDLWrite(enc vdl.Encoder) error

type GroupId

type GroupId string

GroupId is a globally unique syncgroup ID. It is a hash of the syncgroup name.

func (GroupId) VDLIsZero

func (x GroupId) VDLIsZero() bool

func (*GroupId) VDLRead

func (x *GroupId) VDLRead(dec vdl.Decoder) error

func (GroupId) VDLReflect

func (GroupId) VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/services/syncbase/server/interfaces.GroupId"`
})

func (GroupId) VDLWrite

func (x GroupId) VDLWrite(enc vdl.Encoder) error

type Knowledge

type Knowledge map[string]GenVector

Knowledge is a mapping of syncable entities to their generation vectors. These syncable entities could be data prefixes relative to a Database id, or syncgroup oids.

func (Knowledge) DeepCopy

func (in Knowledge) DeepCopy() Knowledge

func (Knowledge) VDLIsZero

func (x Knowledge) VDLIsZero() bool

func (*Knowledge) VDLRead

func (x *Knowledge) VDLRead(dec vdl.Decoder) error

func (Knowledge) VDLReflect

func (Knowledge) VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/services/syncbase/server/interfaces.Knowledge"`
})

func (Knowledge) VDLWrite

func (x Knowledge) VDLWrite(enc vdl.Encoder) error

type LocationData

type LocationData struct {
	WhenSeen time.Time // most recent time when blob thought to have been at location
	IsProxy  bool      // whether the location is a likely proxy to another syncgroup
	IsServer bool      // whether the location is a server that may be revealed outside its syncgroup
}

A LocationData is the information known about a particular location in a Signpost. TODO(m3b): Include mount table information to allow the location to be found.

func (LocationData) VDLIsZero

func (x LocationData) VDLIsZero() bool

func (*LocationData) VDLRead

func (x *LocationData) VDLRead(dec vdl.Decoder) error

func (LocationData) VDLReflect

func (LocationData) VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/services/syncbase/server/interfaces.LocationData"`
})

func (LocationData) VDLWrite

func (x LocationData) VDLWrite(enc vdl.Encoder) error

type LogRec

type LogRec struct {
	Metadata LogRecMetadata
	Value    *vom.RawBytes
}

LogRec represents the on-wire representation of an entire log record: its metadata and data. Value is the actual value of a store object.

func (LogRec) VDLIsZero

func (x LogRec) VDLIsZero() bool

func (*LogRec) VDLRead

func (x *LogRec) VDLRead(dec vdl.Decoder) error

func (LogRec) VDLReflect

func (LogRec) VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/services/syncbase/server/interfaces.LogRec"`
})

func (LogRec) VDLWrite

func (x LogRec) VDLWrite(enc vdl.Encoder) error

type LogRecMetadata

type LogRecMetadata struct {
	// Log related information.
	Id      uint64 // device id that created the log record.
	Gen     uint64 // generation number for the log record.
	RecType byte   // type of log record.
	// Id of the object that was updated. This id is relative to Application
	// and Database names and is the store key for a particular row in a
	// collection.
	ObjId      string
	CurVers    string    // current version number of the object.
	Parents    []string  // 0, 1 or 2 parent versions that the current version is derived from.
	UpdTime    time.Time // timestamp when the update is generated.
	Delete     bool      // indicates whether the update resulted in object being deleted from the store.
	BatchId    uint64    // unique id of the Batch this update belongs to.
	BatchCount uint64    // number of objects in the Batch.
}

LogRecMetadata represents the metadata of a single log record that is exchanged between two peers. Each log record represents a change made to an object in the store.

TODO(hpucha): Add readset/scanset. Look into sending tx metadata only once per transaction.

func (LogRecMetadata) VDLIsZero

func (x LogRecMetadata) VDLIsZero() bool

func (*LogRecMetadata) VDLRead

func (x *LogRecMetadata) VDLRead(dec vdl.Decoder) error

func (LogRecMetadata) VDLReflect

func (LogRecMetadata) VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/services/syncbase/server/interfaces.LogRecMetadata"`
})

func (LogRecMetadata) VDLWrite

func (x LogRecMetadata) VDLWrite(enc vdl.Encoder) error

type PeerToLocationDataMap

type PeerToLocationDataMap map[string]LocationData

A PeerToLocationDataMap is a map from syncbase peer names to LocationData structures.

func (PeerToLocationDataMap) VDLIsZero

func (x PeerToLocationDataMap) VDLIsZero() bool

func (*PeerToLocationDataMap) VDLRead

func (x *PeerToLocationDataMap) VDLRead(dec vdl.Decoder) error

func (PeerToLocationDataMap) VDLReflect

func (PeerToLocationDataMap) VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/services/syncbase/server/interfaces.PeerToLocationDataMap"`
})

func (PeerToLocationDataMap) VDLWrite

func (x PeerToLocationDataMap) VDLWrite(enc vdl.Encoder) error

type Service

type Service interface {
	// St returns the storage engine instance for this service.
	St() store.Store

	// Sync returns the sync instance for this service.
	Sync() SyncServerMethods

	// Database returns a handle for the specified database.
	Database(ctx *context.T, call rpc.ServerCall, dbId wire.Id) (Database, error)

	// DatabaseIds returns ids for all databases.
	DatabaseIds(ctx *context.T, call rpc.ServerCall) ([]wire.Id, error)

	common.Permser
}

Service is an internal interface to the service layer.

type SgDeltaReq

type SgDeltaReq struct {
	DbId syncbase.Id
	Gvs  Knowledge // Contains a genvector per syncgroup.
}

SgDeltaReq contains the initiator's genvectors for the syncgroups it is interested in within a database when requesting deltas for those syncgroups.

func (SgDeltaReq) VDLIsZero

func (x SgDeltaReq) VDLIsZero() bool

func (*SgDeltaReq) VDLRead

func (x *SgDeltaReq) VDLRead(dec vdl.Decoder) error

func (SgDeltaReq) VDLReflect

func (SgDeltaReq) VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/services/syncbase/server/interfaces.SgDeltaReq"`
})

func (SgDeltaReq) VDLWrite

func (x SgDeltaReq) VDLWrite(enc vdl.Encoder) error

type SgPriorities

type SgPriorities map[GroupId]SgPriority

A SgPriorities maps syncgroup IDs to SgPriority structures. It is sent and received in GetDeltas calls to allow the participants to assess who has higher priorities for keeping blobs.

func (SgPriorities) VDLIsZero

func (x SgPriorities) VDLIsZero() bool

func (*SgPriorities) VDLRead

func (x *SgPriorities) VDLRead(dec vdl.Decoder) error

func (SgPriorities) VDLReflect

func (SgPriorities) VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/services/syncbase/server/interfaces.SgPriorities"`
})

func (SgPriorities) VDLWrite

func (x SgPriorities) VDLWrite(enc vdl.Encoder) error

type SgPriority

type SgPriority struct {
	DevType    int32     // device type (BlobDevTypeServer, BlobDevTypeNormal, BlobDevTypeLeaf)
	Distance   float32   // mean number of hops from a server-quality member of the syncgroup
	ServerTime time.Time // when data from a server-quality member reached this device
}

A SgPriority represents data used to decide whether to transfer blob ownership between two devices.

func (SgPriority) VDLIsZero

func (x SgPriority) VDLIsZero() bool

func (*SgPriority) VDLRead

func (x *SgPriority) VDLRead(dec vdl.Decoder) error

func (SgPriority) VDLReflect

func (SgPriority) VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/services/syncbase/server/interfaces.SgPriority"`
})

func (SgPriority) VDLWrite

func (x SgPriority) VDLWrite(enc vdl.Encoder) error

type Signpost

type Signpost struct {
	Locations     PeerToLocationDataMap // Maps name of syncbase that probably has the blob to a LocationData
	SgIds         map[GroupId]struct{}  // SyncGroups through which the BlobRef was learned.
	FetchAttempts uint32                // Number of attempts made to fetch the blob.
}

A Signpost is a hint to syncbase of the device on which a blob may be found. It represents the data known about a blob even when the blob itself is not present on the device.

func (Signpost) VDLIsZero

func (x Signpost) VDLIsZero() bool

func (*Signpost) VDLRead

func (x *Signpost) VDLRead(dec vdl.Decoder) error

func (Signpost) VDLReflect

func (Signpost) VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/services/syncbase/server/interfaces.Signpost"`
})

func (Signpost) VDLWrite

func (x Signpost) VDLWrite(enc vdl.Encoder) error

type SyncClientMethods

type SyncClientMethods interface {
	// GetTime returns metadata related to the Syncbase virtual clock, including
	// system clock values, last NTP timestamp, num reboots, etc.
	//
	// Requires: Always allowed.
	// TODO(ivanpi): Consider adding an ACL or checking syncgroup ACLs.
	GetTime(_ *context.T, req TimeReq, initiator string, _ ...rpc.CallOpt) (TimeResp, error)
	// GetDeltas returns the responder's current generation vectors and all
	// the missing log records when compared to the initiator's generation
	// vectors for one Database for either syncgroup metadata or data.
	// The final result (in DeltaFinalResp) currently includes the
	// syncgroup priorities for blob ownership for the server.
	//
	// Requires: Read on syncgroup.
	// TODO(ivanpi): Consider rechecking Collection Read access.
	// The caller should verify that all received changes (data, ACLs, spec) are
	// signed by a blessing that had the appropriate permission (Write or Admin).
	// TODO(ivanpi): Implement signatures and signature verification.
	GetDeltas(_ *context.T, req DeltaReq, initiator string, _ ...rpc.CallOpt) (SyncGetDeltasClientCall, error)
	// PublishSyncgroup is invoked on the syncgroup name (typically served
	// by a "central" peer) to publish the syncgroup.  It takes the name of
	// Syncbase doing the publishing (the publisher) and returns the name
	// of the Syncbase where the syncgroup is published (the publishee).
	// This allows the publisher and the publishee to learn of each other.
	// When a syncgroup is published, the publishee is given the syncgroup
	// metadata, its current version at the publisher, and the current
	// syncgroup generation vector.  The generation vector serves as a
	// checkpoint at the time of publishing.  The publishing proceeds
	// asynchronously, and the publishee learns the syncgroup history
	// through the routine p2p sync process and determines when it has
	// caught up to the level of knowledge at the time of publishing using
	// the checkpointed generation vector.  Until that point, the publishee
	// locally deems the syncgroup to be in a pending state and does not
	// mutate it.  Thus it locally rejects syncgroup joins or updates to
	// its spec until it is caught up on the syncgroup history.
	//
	// Requires: Always allowed.
	// TODO(ivanpi): Add separate ACL for PublishSyncgroup and check it.
	PublishSyncgroup(_ *context.T, publisher string, sg Syncgroup, version string, genvec GenVector, _ ...rpc.CallOpt) (string, error)
	// JoinSyncgroupAtAdmin is invoked by a prospective syncgroup member's
	// Syncbase on a syncgroup admin. It checks whether the requestor is
	// allowed to join the named syncgroup, and if so, adds the requestor to
	// the syncgroup.  It returns a copy of the updated syncgroup metadata,
	// its version, and the syncgroup generation vector at the time of the
	// join.  Similar to the PublishSyncgroup scenario, the joiner at that
	// point does not have the syncgroup history and locally deems it to be
	// in a pending state and does not mutate it.  This means it rejects
	// local updates to the syncgroup spec or, if it were also an admin on
	// the syncgroup, it would reject syncgroup joins until it is caught up
	// on the syncgroup history through p2p sync.
	//
	// Requires: Read on syncgroup and on all Collections in the syncgroup spec.
	JoinSyncgroupAtAdmin(_ *context.T, dbId syncbase.Id, sgId syncbase.Id, joinerName string, myInfo syncbase.SyncgroupMemberInfo, _ ...rpc.CallOpt) (sg Syncgroup, version string, genvec GenVector, _ error)
	// HaveBlob verifies that the peer has the requested blob, and if
	// present, returns its size.  Otherwise, it returns -1, and the location
	// hints (the Signpost) that the peer has for the blob, filtered to
	// include only data the caller is permitted to see:
	// + Device D reveals a syncgroup SG to the caller C iff
	//   - D is in SG, and
	//   - SG is in the Signpost, and
	//   - at least one of:
	//     - SG is not private, or
	//     - C has permission to join SG.
	// + Device D reveals a location hint L to caller C iff
	//   there is a syncgroup SG such that
	//   - D is in SG, and
	//   - SG is in the Signpost, and
	//   - L is in SG, and
	//   - at least one of:
	//     - SG is not private, or
	//     - C has permission to join SG, or
	//     - L is a blob server in SG.
	HaveBlob(_ *context.T, br syncbase.BlobRef, _ ...rpc.CallOpt) (size int64, signpost Signpost, _ error)
	// FetchBlob fetches the requested blob.
	// It returns a number of blob ownership shares that the server hopes
	// the client will accept using the AcceptedBlobOwnership() call.
	FetchBlob(_ *context.T, br syncbase.BlobRef, mySgPriorities SgPriorities, _ ...rpc.CallOpt) (SyncFetchBlobClientCall, error)
	// Methods for incremental blob transfer. The transfer starts with the
	// receiver making a FetchBlobRecipe call to the sender for a given
	// BlobRef. The sender, in turn, sends the chunk hashes of all the
	// chunks that make up the requested blob (blob recipe). The receiver
	// looks up the chunk hashes in its local blob store, and identifies the
	// missing ones. The receiver then fetches the missing chunks using a
	// FetchChunks call from the sender. Finally, the receiver finishes the
	// blob fetch by combining the chunks obtained over the network with the
	// already available local chunks as per the blob recipe.
	// callerName is the syncbase Id of the caller, expressed as a string.
	// FetchBlobRecipe returns a number of blob ownership shares that the
	// server hopes the client will accept for each syncgroup using the
	// AcceptedBlobOwnership() call.
	FetchBlobRecipe(_ *context.T, br syncbase.BlobRef, callerName string, mySgPriorities SgPriorities, _ ...rpc.CallOpt) (SyncFetchBlobRecipeClientCall, error)
	FetchChunks(*context.T, ...rpc.CallOpt) (SyncFetchChunksClientCall, error)
	// RequestTakeBlobs indicates that the caller wishes the server to take
	// some blob ownership shares for various syncgroups for the specified blobs.
	// If the server chooses to act on the request, it may call FetchBlob/FetchBlobRecipe,
	// and ultimately AcceptedBlobOwnership().
	// callerName is the syncbase Id of the caller, expressed as a string.
	RequestTakeBlobs(_ *context.T, callerName string, blobRefToShares map[syncbase.BlobRef]BlobSharesBySyncgroup, _ ...rpc.CallOpt) error
	// AcceptedBlobOwnership tells the server that the client callerName (a
	// syncbase Id expressed as a string) has accepted blob ownership of a
	// specified number of shares for blob br.  The server may decrement
	// its share count by up to this number.  It is safe for the server to
	// decrement its share count by fewer than the number of shares another
	// device has taken responsibility for, but unsafe to decrement it by
	// more than that that number.  It returns a hint as to whether the
	// server is likely to keep the blob itself, plus its syncbase Id
	// expressed as a string.
	AcceptedBlobOwnership(_ *context.T, br syncbase.BlobRef, callerName string, shares BlobSharesBySyncgroup, _ ...rpc.CallOpt) (serverName string, keepingBlob bool, _ error)
	// GetBlobShares returns the number of ownership shares for the specified blob
	// held by the server.  It is used by the DevModeGetBlobShares() call in the
	// service.  It uses the "map[string]int32" type, rather than
	// interfaces.BlobSharesBySyncgroup, so that the client of this call code doesn't
	// need to reach into the sync service's type definitions.
	GetBlobShares(_ *context.T, br syncbase.BlobRef, _ ...rpc.CallOpt) (map[string]int32, error)
}

SyncClientMethods is the client interface containing Sync methods.

Sync defines methods for data exchange between Syncbases. TODO(hpucha): Flesh this out further.

type SyncClientStub

type SyncClientStub interface {
	SyncClientMethods
	rpc.UniversalServiceMethods
}

SyncClientStub adds universal methods to SyncClientMethods.

func SyncClient

func SyncClient(name string) SyncClientStub

SyncClient returns a client stub for Sync.

type SyncFetchBlobClientCall

type SyncFetchBlobClientCall interface {
	SyncFetchBlobClientStream
	// Finish blocks until the server is done, and returns the positional return
	// values for call.
	//
	// Finish returns immediately if the call has been canceled; depending on the
	// timing the output could either be an error signaling cancelation, or the
	// valid positional return values from the server.
	//
	// Calling Finish is mandatory for releasing stream resources, unless the call
	// has been canceled or any of the other methods return an error.  Finish should
	// be called at most once.
	Finish() (shares BlobSharesBySyncgroup, _ error)
}

SyncFetchBlobClientCall represents the call returned from Sync.FetchBlob.

type SyncFetchBlobClientStream

type SyncFetchBlobClientStream interface {
	// RecvStream returns the receiver side of the Sync.FetchBlob client stream.
	RecvStream() interface {
		// Advance stages an item so that it may be retrieved via Value.  Returns
		// true iff there is an item to retrieve.  Advance must be called before
		// Value is called.  May block if an item is not available.
		Advance() bool
		// Value returns the item that was staged by Advance.  May panic if Advance
		// returned false or was not called.  Never blocks.
		Value() []byte
		// Err returns any error encountered by Advance.  Never blocks.
		Err() error
	}
}

SyncFetchBlobClientStream is the client stream for Sync.FetchBlob.

type SyncFetchBlobRecipeClientCall

type SyncFetchBlobRecipeClientCall interface {
	SyncFetchBlobRecipeClientStream
	// Finish blocks until the server is done, and returns the positional return
	// values for call.
	//
	// Finish returns immediately if the call has been canceled; depending on the
	// timing the output could either be an error signaling cancelation, or the
	// valid positional return values from the server.
	//
	// Calling Finish is mandatory for releasing stream resources, unless the call
	// has been canceled or any of the other methods return an error.  Finish should
	// be called at most once.
	Finish() (shares BlobSharesBySyncgroup, _ error)
}

SyncFetchBlobRecipeClientCall represents the call returned from Sync.FetchBlobRecipe.

type SyncFetchBlobRecipeClientStream

type SyncFetchBlobRecipeClientStream interface {
	// RecvStream returns the receiver side of the Sync.FetchBlobRecipe client stream.
	RecvStream() interface {
		// Advance stages an item so that it may be retrieved via Value.  Returns
		// true iff there is an item to retrieve.  Advance must be called before
		// Value is called.  May block if an item is not available.
		Advance() bool
		// Value returns the item that was staged by Advance.  May panic if Advance
		// returned false or was not called.  Never blocks.
		Value() ChunkHash
		// Err returns any error encountered by Advance.  Never blocks.
		Err() error
	}
}

SyncFetchBlobRecipeClientStream is the client stream for Sync.FetchBlobRecipe.

type SyncFetchBlobRecipeServerCall

type SyncFetchBlobRecipeServerCall interface {
	rpc.ServerCall
	SyncFetchBlobRecipeServerStream
}

SyncFetchBlobRecipeServerCall represents the context passed to Sync.FetchBlobRecipe.

type SyncFetchBlobRecipeServerCallStub

type SyncFetchBlobRecipeServerCallStub struct {
	rpc.StreamServerCall
}

SyncFetchBlobRecipeServerCallStub is a wrapper that converts rpc.StreamServerCall into a typesafe stub that implements SyncFetchBlobRecipeServerCall.

func (*SyncFetchBlobRecipeServerCallStub) Init

Init initializes SyncFetchBlobRecipeServerCallStub from rpc.StreamServerCall.

func (*SyncFetchBlobRecipeServerCallStub) SendStream

func (s *SyncFetchBlobRecipeServerCallStub) SendStream() interface {
	Send(item ChunkHash) error
}

SendStream returns the send side of the Sync.FetchBlobRecipe server stream.

type SyncFetchBlobRecipeServerStream

type SyncFetchBlobRecipeServerStream interface {
	// SendStream returns the send side of the Sync.FetchBlobRecipe server stream.
	SendStream() interface {
		// Send places the item onto the output stream.  Returns errors encountered
		// while sending.  Blocks if there is no buffer space; will unblock when
		// buffer space is available.
		Send(item ChunkHash) error
	}
}

SyncFetchBlobRecipeServerStream is the server stream for Sync.FetchBlobRecipe.

type SyncFetchBlobServerCall

type SyncFetchBlobServerCall interface {
	rpc.ServerCall
	SyncFetchBlobServerStream
}

SyncFetchBlobServerCall represents the context passed to Sync.FetchBlob.

type SyncFetchBlobServerCallStub

type SyncFetchBlobServerCallStub struct {
	rpc.StreamServerCall
}

SyncFetchBlobServerCallStub is a wrapper that converts rpc.StreamServerCall into a typesafe stub that implements SyncFetchBlobServerCall.

func (*SyncFetchBlobServerCallStub) Init

Init initializes SyncFetchBlobServerCallStub from rpc.StreamServerCall.

func (*SyncFetchBlobServerCallStub) SendStream

func (s *SyncFetchBlobServerCallStub) SendStream() interface {
	Send(item []byte) error
}

SendStream returns the send side of the Sync.FetchBlob server stream.

type SyncFetchBlobServerStream

type SyncFetchBlobServerStream interface {
	// SendStream returns the send side of the Sync.FetchBlob server stream.
	SendStream() interface {
		// Send places the item onto the output stream.  Returns errors encountered
		// while sending.  Blocks if there is no buffer space; will unblock when
		// buffer space is available.
		Send(item []byte) error
	}
}

SyncFetchBlobServerStream is the server stream for Sync.FetchBlob.

type SyncFetchChunksClientCall

type SyncFetchChunksClientCall interface {
	SyncFetchChunksClientStream
	// Finish performs the equivalent of SendStream().Close, then blocks until
	// the server is done, and returns the positional return values for the call.
	//
	// Finish returns immediately if the call has been canceled; depending on the
	// timing the output could either be an error signaling cancelation, or the
	// valid positional return values from the server.
	//
	// Calling Finish is mandatory for releasing stream resources, unless the call
	// has been canceled or any of the other methods return an error.  Finish should
	// be called at most once.
	Finish() error
}

SyncFetchChunksClientCall represents the call returned from Sync.FetchChunks.

type SyncFetchChunksClientStream

type SyncFetchChunksClientStream interface {
	// RecvStream returns the receiver side of the Sync.FetchChunks client stream.
	RecvStream() interface {
		// Advance stages an item so that it may be retrieved via Value.  Returns
		// true iff there is an item to retrieve.  Advance must be called before
		// Value is called.  May block if an item is not available.
		Advance() bool
		// Value returns the item that was staged by Advance.  May panic if Advance
		// returned false or was not called.  Never blocks.
		Value() ChunkData
		// Err returns any error encountered by Advance.  Never blocks.
		Err() error
	}
	// SendStream returns the send side of the Sync.FetchChunks client stream.
	SendStream() interface {
		// Send places the item onto the output stream.  Returns errors
		// encountered while sending, or if Send is called after Close or
		// the stream has been canceled.  Blocks if there is no buffer
		// space; will unblock when buffer space is available or after
		// the stream has been canceled.
		Send(item ChunkHash) error
		// Close indicates to the server that no more items will be sent;
		// server Recv calls will receive io.EOF after all sent items.
		// This is an optional call - e.g. a client might call Close if it
		// needs to continue receiving items from the server after it's
		// done sending.  Returns errors encountered while closing, or if
		// Close is called after the stream has been canceled.  Like Send,
		// blocks if there is no buffer space available.
		Close() error
	}
}

SyncFetchChunksClientStream is the client stream for Sync.FetchChunks.

type SyncFetchChunksServerCall

type SyncFetchChunksServerCall interface {
	rpc.ServerCall
	SyncFetchChunksServerStream
}

SyncFetchChunksServerCall represents the context passed to Sync.FetchChunks.

type SyncFetchChunksServerCallStub

type SyncFetchChunksServerCallStub struct {
	rpc.StreamServerCall
	// contains filtered or unexported fields
}

SyncFetchChunksServerCallStub is a wrapper that converts rpc.StreamServerCall into a typesafe stub that implements SyncFetchChunksServerCall.

func (*SyncFetchChunksServerCallStub) Init

Init initializes SyncFetchChunksServerCallStub from rpc.StreamServerCall.

func (*SyncFetchChunksServerCallStub) RecvStream

func (s *SyncFetchChunksServerCallStub) RecvStream() interface {
	Advance() bool
	Value() ChunkHash
	Err() error
}

RecvStream returns the receiver side of the Sync.FetchChunks server stream.

func (*SyncFetchChunksServerCallStub) SendStream

func (s *SyncFetchChunksServerCallStub) SendStream() interface {
	Send(item ChunkData) error
}

SendStream returns the send side of the Sync.FetchChunks server stream.

type SyncFetchChunksServerStream

type SyncFetchChunksServerStream interface {
	// RecvStream returns the receiver side of the Sync.FetchChunks server stream.
	RecvStream() interface {
		// Advance stages an item so that it may be retrieved via Value.  Returns
		// true iff there is an item to retrieve.  Advance must be called before
		// Value is called.  May block if an item is not available.
		Advance() bool
		// Value returns the item that was staged by Advance.  May panic if Advance
		// returned false or was not called.  Never blocks.
		Value() ChunkHash
		// Err returns any error encountered by Advance.  Never blocks.
		Err() error
	}
	// SendStream returns the send side of the Sync.FetchChunks server stream.
	SendStream() interface {
		// Send places the item onto the output stream.  Returns errors encountered
		// while sending.  Blocks if there is no buffer space; will unblock when
		// buffer space is available.
		Send(item ChunkData) error
	}
}

SyncFetchChunksServerStream is the server stream for Sync.FetchChunks.

type SyncGetDeltasClientCall

type SyncGetDeltasClientCall interface {
	SyncGetDeltasClientStream
	// Finish blocks until the server is done, and returns the positional return
	// values for call.
	//
	// Finish returns immediately if the call has been canceled; depending on the
	// timing the output could either be an error signaling cancelation, or the
	// valid positional return values from the server.
	//
	// Calling Finish is mandatory for releasing stream resources, unless the call
	// has been canceled or any of the other methods return an error.  Finish should
	// be called at most once.
	Finish() (DeltaFinalResp, error)
}

SyncGetDeltasClientCall represents the call returned from Sync.GetDeltas.

type SyncGetDeltasClientStream

type SyncGetDeltasClientStream interface {
	// RecvStream returns the receiver side of the Sync.GetDeltas client stream.
	RecvStream() interface {
		// Advance stages an item so that it may be retrieved via Value.  Returns
		// true iff there is an item to retrieve.  Advance must be called before
		// Value is called.  May block if an item is not available.
		Advance() bool
		// Value returns the item that was staged by Advance.  May panic if Advance
		// returned false or was not called.  Never blocks.
		Value() DeltaResp
		// Err returns any error encountered by Advance.  Never blocks.
		Err() error
	}
}

SyncGetDeltasClientStream is the client stream for Sync.GetDeltas.

type SyncGetDeltasServerCall

type SyncGetDeltasServerCall interface {
	rpc.ServerCall
	SyncGetDeltasServerStream
}

SyncGetDeltasServerCall represents the context passed to Sync.GetDeltas.

type SyncGetDeltasServerCallStub

type SyncGetDeltasServerCallStub struct {
	rpc.StreamServerCall
}

SyncGetDeltasServerCallStub is a wrapper that converts rpc.StreamServerCall into a typesafe stub that implements SyncGetDeltasServerCall.

func (*SyncGetDeltasServerCallStub) Init

Init initializes SyncGetDeltasServerCallStub from rpc.StreamServerCall.

func (*SyncGetDeltasServerCallStub) SendStream

func (s *SyncGetDeltasServerCallStub) SendStream() interface {
	Send(item DeltaResp) error
}

SendStream returns the send side of the Sync.GetDeltas server stream.

type SyncGetDeltasServerStream

type SyncGetDeltasServerStream interface {
	// SendStream returns the send side of the Sync.GetDeltas server stream.
	SendStream() interface {
		// Send places the item onto the output stream.  Returns errors encountered
		// while sending.  Blocks if there is no buffer space; will unblock when
		// buffer space is available.
		Send(item DeltaResp) error
	}
}

SyncGetDeltasServerStream is the server stream for Sync.GetDeltas.

type SyncServerMethods

type SyncServerMethods interface {
	// GetTime returns metadata related to the Syncbase virtual clock, including
	// system clock values, last NTP timestamp, num reboots, etc.
	//
	// Requires: Always allowed.
	// TODO(ivanpi): Consider adding an ACL or checking syncgroup ACLs.
	GetTime(_ *context.T, _ rpc.ServerCall, req TimeReq, initiator string) (TimeResp, error)
	// GetDeltas returns the responder's current generation vectors and all
	// the missing log records when compared to the initiator's generation
	// vectors for one Database for either syncgroup metadata or data.
	// The final result (in DeltaFinalResp) currently includes the
	// syncgroup priorities for blob ownership for the server.
	//
	// Requires: Read on syncgroup.
	// TODO(ivanpi): Consider rechecking Collection Read access.
	// The caller should verify that all received changes (data, ACLs, spec) are
	// signed by a blessing that had the appropriate permission (Write or Admin).
	// TODO(ivanpi): Implement signatures and signature verification.
	GetDeltas(_ *context.T, _ SyncGetDeltasServerCall, req DeltaReq, initiator string) (DeltaFinalResp, error)
	// PublishSyncgroup is invoked on the syncgroup name (typically served
	// by a "central" peer) to publish the syncgroup.  It takes the name of
	// Syncbase doing the publishing (the publisher) and returns the name
	// of the Syncbase where the syncgroup is published (the publishee).
	// This allows the publisher and the publishee to learn of each other.
	// When a syncgroup is published, the publishee is given the syncgroup
	// metadata, its current version at the publisher, and the current
	// syncgroup generation vector.  The generation vector serves as a
	// checkpoint at the time of publishing.  The publishing proceeds
	// asynchronously, and the publishee learns the syncgroup history
	// through the routine p2p sync process and determines when it has
	// caught up to the level of knowledge at the time of publishing using
	// the checkpointed generation vector.  Until that point, the publishee
	// locally deems the syncgroup to be in a pending state and does not
	// mutate it.  Thus it locally rejects syncgroup joins or updates to
	// its spec until it is caught up on the syncgroup history.
	//
	// Requires: Always allowed.
	// TODO(ivanpi): Add separate ACL for PublishSyncgroup and check it.
	PublishSyncgroup(_ *context.T, _ rpc.ServerCall, publisher string, sg Syncgroup, version string, genvec GenVector) (string, error)
	// JoinSyncgroupAtAdmin is invoked by a prospective syncgroup member's
	// Syncbase on a syncgroup admin. It checks whether the requestor is
	// allowed to join the named syncgroup, and if so, adds the requestor to
	// the syncgroup.  It returns a copy of the updated syncgroup metadata,
	// its version, and the syncgroup generation vector at the time of the
	// join.  Similar to the PublishSyncgroup scenario, the joiner at that
	// point does not have the syncgroup history and locally deems it to be
	// in a pending state and does not mutate it.  This means it rejects
	// local updates to the syncgroup spec or, if it were also an admin on
	// the syncgroup, it would reject syncgroup joins until it is caught up
	// on the syncgroup history through p2p sync.
	//
	// Requires: Read on syncgroup and on all Collections in the syncgroup spec.
	JoinSyncgroupAtAdmin(_ *context.T, _ rpc.ServerCall, dbId syncbase.Id, sgId syncbase.Id, joinerName string, myInfo syncbase.SyncgroupMemberInfo) (sg Syncgroup, version string, genvec GenVector, _ error)
	// HaveBlob verifies that the peer has the requested blob, and if
	// present, returns its size.  Otherwise, it returns -1, and the location
	// hints (the Signpost) that the peer has for the blob, filtered to
	// include only data the caller is permitted to see:
	// + Device D reveals a syncgroup SG to the caller C iff
	//   - D is in SG, and
	//   - SG is in the Signpost, and
	//   - at least one of:
	//     - SG is not private, or
	//     - C has permission to join SG.
	// + Device D reveals a location hint L to caller C iff
	//   there is a syncgroup SG such that
	//   - D is in SG, and
	//   - SG is in the Signpost, and
	//   - L is in SG, and
	//   - at least one of:
	//     - SG is not private, or
	//     - C has permission to join SG, or
	//     - L is a blob server in SG.
	HaveBlob(_ *context.T, _ rpc.ServerCall, br syncbase.BlobRef) (size int64, signpost Signpost, _ error)
	// FetchBlob fetches the requested blob.
	// It returns a number of blob ownership shares that the server hopes
	// the client will accept using the AcceptedBlobOwnership() call.
	FetchBlob(_ *context.T, _ SyncFetchBlobServerCall, br syncbase.BlobRef, mySgPriorities SgPriorities) (shares BlobSharesBySyncgroup, _ error)
	// Methods for incremental blob transfer. The transfer starts with the
	// receiver making a FetchBlobRecipe call to the sender for a given
	// BlobRef. The sender, in turn, sends the chunk hashes of all the
	// chunks that make up the requested blob (blob recipe). The receiver
	// looks up the chunk hashes in its local blob store, and identifies the
	// missing ones. The receiver then fetches the missing chunks using a
	// FetchChunks call from the sender. Finally, the receiver finishes the
	// blob fetch by combining the chunks obtained over the network with the
	// already available local chunks as per the blob recipe.
	// callerName is the syncbase Id of the caller, expressed as a string.
	// FetchBlobRecipe returns a number of blob ownership shares that the
	// server hopes the client will accept for each syncgroup using the
	// AcceptedBlobOwnership() call.
	FetchBlobRecipe(_ *context.T, _ SyncFetchBlobRecipeServerCall, br syncbase.BlobRef, callerName string, mySgPriorities SgPriorities) (shares BlobSharesBySyncgroup, _ error)
	FetchChunks(*context.T, SyncFetchChunksServerCall) error
	// RequestTakeBlobs indicates that the caller wishes the server to take
	// some blob ownership shares for various syncgroups for the specified blobs.
	// If the server chooses to act on the request, it may call FetchBlob/FetchBlobRecipe,
	// and ultimately AcceptedBlobOwnership().
	// callerName is the syncbase Id of the caller, expressed as a string.
	RequestTakeBlobs(_ *context.T, _ rpc.ServerCall, callerName string, blobRefToShares map[syncbase.BlobRef]BlobSharesBySyncgroup) error
	// AcceptedBlobOwnership tells the server that the client callerName (a
	// syncbase Id expressed as a string) has accepted blob ownership of a
	// specified number of shares for blob br.  The server may decrement
	// its share count by up to this number.  It is safe for the server to
	// decrement its share count by fewer than the number of shares another
	// device has taken responsibility for, but unsafe to decrement it by
	// more than that that number.  It returns a hint as to whether the
	// server is likely to keep the blob itself, plus its syncbase Id
	// expressed as a string.
	AcceptedBlobOwnership(_ *context.T, _ rpc.ServerCall, br syncbase.BlobRef, callerName string, shares BlobSharesBySyncgroup) (serverName string, keepingBlob bool, _ error)
	// GetBlobShares returns the number of ownership shares for the specified blob
	// held by the server.  It is used by the DevModeGetBlobShares() call in the
	// service.  It uses the "map[string]int32" type, rather than
	// interfaces.BlobSharesBySyncgroup, so that the client of this call code doesn't
	// need to reach into the sync service's type definitions.
	GetBlobShares(_ *context.T, _ rpc.ServerCall, br syncbase.BlobRef) (map[string]int32, error)
}

SyncServerMethods is the interface a server writer implements for Sync.

Sync defines methods for data exchange between Syncbases. TODO(hpucha): Flesh this out further.

type SyncServerStub

type SyncServerStub interface {
	SyncServerStubMethods
	// Describe the Sync interfaces.
	Describe__() []rpc.InterfaceDesc
}

SyncServerStub adds universal methods to SyncServerStubMethods.

func SyncServer

func SyncServer(impl SyncServerMethods) SyncServerStub

SyncServer returns a server stub for Sync. It converts an implementation of SyncServerMethods into an object that may be used by rpc.Server.

type SyncServerStubMethods

type SyncServerStubMethods interface {
	// GetTime returns metadata related to the Syncbase virtual clock, including
	// system clock values, last NTP timestamp, num reboots, etc.
	//
	// Requires: Always allowed.
	// TODO(ivanpi): Consider adding an ACL or checking syncgroup ACLs.
	GetTime(_ *context.T, _ rpc.ServerCall, req TimeReq, initiator string) (TimeResp, error)
	// GetDeltas returns the responder's current generation vectors and all
	// the missing log records when compared to the initiator's generation
	// vectors for one Database for either syncgroup metadata or data.
	// The final result (in DeltaFinalResp) currently includes the
	// syncgroup priorities for blob ownership for the server.
	//
	// Requires: Read on syncgroup.
	// TODO(ivanpi): Consider rechecking Collection Read access.
	// The caller should verify that all received changes (data, ACLs, spec) are
	// signed by a blessing that had the appropriate permission (Write or Admin).
	// TODO(ivanpi): Implement signatures and signature verification.
	GetDeltas(_ *context.T, _ *SyncGetDeltasServerCallStub, req DeltaReq, initiator string) (DeltaFinalResp, error)
	// PublishSyncgroup is invoked on the syncgroup name (typically served
	// by a "central" peer) to publish the syncgroup.  It takes the name of
	// Syncbase doing the publishing (the publisher) and returns the name
	// of the Syncbase where the syncgroup is published (the publishee).
	// This allows the publisher and the publishee to learn of each other.
	// When a syncgroup is published, the publishee is given the syncgroup
	// metadata, its current version at the publisher, and the current
	// syncgroup generation vector.  The generation vector serves as a
	// checkpoint at the time of publishing.  The publishing proceeds
	// asynchronously, and the publishee learns the syncgroup history
	// through the routine p2p sync process and determines when it has
	// caught up to the level of knowledge at the time of publishing using
	// the checkpointed generation vector.  Until that point, the publishee
	// locally deems the syncgroup to be in a pending state and does not
	// mutate it.  Thus it locally rejects syncgroup joins or updates to
	// its spec until it is caught up on the syncgroup history.
	//
	// Requires: Always allowed.
	// TODO(ivanpi): Add separate ACL for PublishSyncgroup and check it.
	PublishSyncgroup(_ *context.T, _ rpc.ServerCall, publisher string, sg Syncgroup, version string, genvec GenVector) (string, error)
	// JoinSyncgroupAtAdmin is invoked by a prospective syncgroup member's
	// Syncbase on a syncgroup admin. It checks whether the requestor is
	// allowed to join the named syncgroup, and if so, adds the requestor to
	// the syncgroup.  It returns a copy of the updated syncgroup metadata,
	// its version, and the syncgroup generation vector at the time of the
	// join.  Similar to the PublishSyncgroup scenario, the joiner at that
	// point does not have the syncgroup history and locally deems it to be
	// in a pending state and does not mutate it.  This means it rejects
	// local updates to the syncgroup spec or, if it were also an admin on
	// the syncgroup, it would reject syncgroup joins until it is caught up
	// on the syncgroup history through p2p sync.
	//
	// Requires: Read on syncgroup and on all Collections in the syncgroup spec.
	JoinSyncgroupAtAdmin(_ *context.T, _ rpc.ServerCall, dbId syncbase.Id, sgId syncbase.Id, joinerName string, myInfo syncbase.SyncgroupMemberInfo) (sg Syncgroup, version string, genvec GenVector, _ error)
	// HaveBlob verifies that the peer has the requested blob, and if
	// present, returns its size.  Otherwise, it returns -1, and the location
	// hints (the Signpost) that the peer has for the blob, filtered to
	// include only data the caller is permitted to see:
	// + Device D reveals a syncgroup SG to the caller C iff
	//   - D is in SG, and
	//   - SG is in the Signpost, and
	//   - at least one of:
	//     - SG is not private, or
	//     - C has permission to join SG.
	// + Device D reveals a location hint L to caller C iff
	//   there is a syncgroup SG such that
	//   - D is in SG, and
	//   - SG is in the Signpost, and
	//   - L is in SG, and
	//   - at least one of:
	//     - SG is not private, or
	//     - C has permission to join SG, or
	//     - L is a blob server in SG.
	HaveBlob(_ *context.T, _ rpc.ServerCall, br syncbase.BlobRef) (size int64, signpost Signpost, _ error)
	// FetchBlob fetches the requested blob.
	// It returns a number of blob ownership shares that the server hopes
	// the client will accept using the AcceptedBlobOwnership() call.
	FetchBlob(_ *context.T, _ *SyncFetchBlobServerCallStub, br syncbase.BlobRef, mySgPriorities SgPriorities) (shares BlobSharesBySyncgroup, _ error)
	// Methods for incremental blob transfer. The transfer starts with the
	// receiver making a FetchBlobRecipe call to the sender for a given
	// BlobRef. The sender, in turn, sends the chunk hashes of all the
	// chunks that make up the requested blob (blob recipe). The receiver
	// looks up the chunk hashes in its local blob store, and identifies the
	// missing ones. The receiver then fetches the missing chunks using a
	// FetchChunks call from the sender. Finally, the receiver finishes the
	// blob fetch by combining the chunks obtained over the network with the
	// already available local chunks as per the blob recipe.
	// callerName is the syncbase Id of the caller, expressed as a string.
	// FetchBlobRecipe returns a number of blob ownership shares that the
	// server hopes the client will accept for each syncgroup using the
	// AcceptedBlobOwnership() call.
	FetchBlobRecipe(_ *context.T, _ *SyncFetchBlobRecipeServerCallStub, br syncbase.BlobRef, callerName string, mySgPriorities SgPriorities) (shares BlobSharesBySyncgroup, _ error)
	FetchChunks(*context.T, *SyncFetchChunksServerCallStub) error
	// RequestTakeBlobs indicates that the caller wishes the server to take
	// some blob ownership shares for various syncgroups for the specified blobs.
	// If the server chooses to act on the request, it may call FetchBlob/FetchBlobRecipe,
	// and ultimately AcceptedBlobOwnership().
	// callerName is the syncbase Id of the caller, expressed as a string.
	RequestTakeBlobs(_ *context.T, _ rpc.ServerCall, callerName string, blobRefToShares map[syncbase.BlobRef]BlobSharesBySyncgroup) error
	// AcceptedBlobOwnership tells the server that the client callerName (a
	// syncbase Id expressed as a string) has accepted blob ownership of a
	// specified number of shares for blob br.  The server may decrement
	// its share count by up to this number.  It is safe for the server to
	// decrement its share count by fewer than the number of shares another
	// device has taken responsibility for, but unsafe to decrement it by
	// more than that that number.  It returns a hint as to whether the
	// server is likely to keep the blob itself, plus its syncbase Id
	// expressed as a string.
	AcceptedBlobOwnership(_ *context.T, _ rpc.ServerCall, br syncbase.BlobRef, callerName string, shares BlobSharesBySyncgroup) (serverName string, keepingBlob bool, _ error)
	// GetBlobShares returns the number of ownership shares for the specified blob
	// held by the server.  It is used by the DevModeGetBlobShares() call in the
	// service.  It uses the "map[string]int32" type, rather than
	// interfaces.BlobSharesBySyncgroup, so that the client of this call code doesn't
	// need to reach into the sync service's type definitions.
	GetBlobShares(_ *context.T, _ rpc.ServerCall, br syncbase.BlobRef) (map[string]int32, error)
}

SyncServerStubMethods is the server interface containing Sync methods, as expected by rpc.Server. The only difference between this interface and SyncServerMethods is the streaming methods.

type Syncgroup

type Syncgroup struct {
	Id          syncbase.Id                     // the relative syncgroup Id chosen by app
	SpecVersion string                          // version on syncgroup spec for concurrency control
	Spec        syncbase.SyncgroupSpec          // app-given specification
	Creator     string                          // Creator's Vanadium name
	DbId        syncbase.Id                     // Globally unique database id
	Status      SyncgroupStatus                 // Status of the syncgroup
	Joiners     map[string]SyncgroupMemberState // map of joiners to their metadata
}

Syncgroup contains the state of a syncgroup.

func (*Syncgroup) GetPerms

func (sg *Syncgroup) GetPerms() access.Permissions

func (Syncgroup) VDLIsZero

func (x Syncgroup) VDLIsZero() bool

func (*Syncgroup) VDLRead

func (x *Syncgroup) VDLRead(dec vdl.Decoder) error

func (Syncgroup) VDLReflect

func (Syncgroup) VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/services/syncbase/server/interfaces.Syncgroup"`
})

func (Syncgroup) VDLWrite

func (x Syncgroup) VDLWrite(enc vdl.Encoder) error

type SyncgroupMemberState

type SyncgroupMemberState struct {
	// Timestamp of when the member last joined/left the syncgroup. This timestamp is updated
	// even when an existing member rejoins a syncgroup. Represented as Unix time.
	WhenUpdated int64
	// If set then this record indicates that this member has left the group. The SyncgroupMember
	// entry is retained after a delete so that it can be used during conflict resolution, when
	// one node indicates that the member has left the group and another says that the member
	// is still in the group.
	HasLeft bool
	// Information supplied when requesting a join.
	MemberInfo syncbase.SyncgroupMemberInfo
}

SyncgroupMemberState contains information about a joiner and the internal bookkeeping state required for resolving conflicts on this joiner's join/leave activity.

func (SyncgroupMemberState) VDLIsZero

func (x SyncgroupMemberState) VDLIsZero() bool

func (*SyncgroupMemberState) VDLRead

func (x *SyncgroupMemberState) VDLRead(dec vdl.Decoder) error

func (SyncgroupMemberState) VDLReflect

func (SyncgroupMemberState) VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/services/syncbase/server/interfaces.SyncgroupMemberState"`
})

func (SyncgroupMemberState) VDLWrite

func (x SyncgroupMemberState) VDLWrite(enc vdl.Encoder) error

type SyncgroupStatus

type SyncgroupStatus int

Possible states for a syncgroup.

const (
	SyncgroupStatusPublishPending SyncgroupStatus = iota
	SyncgroupStatusPublishRejected
	SyncgroupStatusRunning
)

func SyncgroupStatusFromString

func SyncgroupStatusFromString(label string) (x SyncgroupStatus, err error)

SyncgroupStatusFromString creates a SyncgroupStatus from a string label.

func (*SyncgroupStatus) Set

func (x *SyncgroupStatus) Set(label string) error

Set assigns label to x.

func (SyncgroupStatus) String

func (x SyncgroupStatus) String() string

String returns the string label of x.

func (SyncgroupStatus) VDLIsZero

func (x SyncgroupStatus) VDLIsZero() bool

func (*SyncgroupStatus) VDLRead

func (x *SyncgroupStatus) VDLRead(dec vdl.Decoder) error

func (SyncgroupStatus) VDLReflect

func (SyncgroupStatus) VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/services/syncbase/server/interfaces.SyncgroupStatus"`
	Enum struct{ PublishPending, PublishRejected, Running string }
})

func (SyncgroupStatus) VDLWrite

func (x SyncgroupStatus) VDLWrite(enc vdl.Encoder) error

type TimeReq

type TimeReq struct {
	SendTs time.Time
}

TimeReq contains the send timestamp from the requester.

func (TimeReq) VDLIsZero

func (x TimeReq) VDLIsZero() bool

func (*TimeReq) VDLRead

func (x *TimeReq) VDLRead(dec vdl.Decoder) error

func (TimeReq) VDLReflect

func (TimeReq) VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/services/syncbase/server/interfaces.TimeReq"`
})

func (TimeReq) VDLWrite

func (x TimeReq) VDLWrite(enc vdl.Encoder) error

type TimeResp

type TimeResp struct {
	OrigTs time.Time // when we sent request
	RecvTs time.Time // when peer received request
	SendTs time.Time // when peer sent response
	// NTP server timestamp from the most recent NTP sync, or zero value if none.
	// Note, the NTP sync may have been performed by some peer device.
	LastNtpTs time.Time
	// Number of reboots since last NTP sync, accumulated across all hops of p2p
	// clock sync.
	NumReboots uint16
	// Number of sync hops between peer's device and its source of LastNtpTs.
	NumHops uint16
}

TimeResp contains information needed by the requester to estimate the difference between the two vclocks and to decide whether to incorporate the peer's vclock data.

func (TimeResp) VDLIsZero

func (x TimeResp) VDLIsZero() bool

func (*TimeResp) VDLRead

func (x *TimeResp) VDLRead(dec vdl.Decoder) error

func (TimeResp) VDLReflect

func (TimeResp) VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/services/syncbase/server/interfaces.TimeResp"`
})

func (TimeResp) VDLWrite

func (x TimeResp) VDLWrite(enc vdl.Encoder) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL