blob: 80b46a04a437ed033c346415f2b1ac4e53b62df2 [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 interfaces
import (
wire "v.io/v23/services/syncbase/nosql"
"v.io/v23/security/access"
)
// Sync defines methods for data exchange between Syncbases.
// TODO(hpucha): Flesh this out further.
type Sync interface {
// GetDeltas returns the responder's current generation vector and all
// the missing log records when compared to the initiator's generation
// vector for one Database for either SyncGroup metadata or data.
GetDeltas(req DeltaReq, initiator string) stream<_, DeltaResp> error {access.Read}
// SyncGroup-related methods.
// 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.
PublishSyncGroup(publisher string, sg SyncGroup, version string, genvec PrefixGenVector) (string | error) {access.Write}
// 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.
JoinSyncGroupAtAdmin(sgName, joinerName string, myInfo wire.SyncGroupMemberInfo) (sg SyncGroup, version string, genvec PrefixGenVector | error) {access.Read}
// BlobSync methods.
// HaveBlob verifies that the peer has the requested blob, and if
// present, returns its size.
HaveBlob(br wire.BlobRef) (int64 | error)
// FetchBlob fetches the requested blob.
FetchBlob(br wire.BlobRef) stream<_, []byte> 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.
FetchBlobRecipe(br wire.BlobRef) stream<_, ChunkHash> error
FetchChunks() stream<ChunkHash, ChunkData> error
}
error (
DupSyncGroupPublish(name string) {"en": "duplicate publish on SyncGroup: {name}"}
)