blob: 4e11e3ffeb97b90d7ba5a2e642e2b7b91745049d [file] [log] [blame]
Himabindu Puchafb26a832015-05-20 15:37:50 -07001// Copyright 2015 The Vanadium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
Himabindu Puchaf9ec56f2015-06-02 11:34:05 -07005package interfaces
Himabindu Puchafb26a832015-05-20 15:37:50 -07006
Himabindu Pucha12e1a122015-06-08 15:59:09 -07007import (
Adam Sadovskyf2efeb52015-08-31 14:17:49 -07008 wire "v.io/v23/services/syncbase/nosql"
Sergey Rogulenkoc2e60f62015-06-23 14:50:58 -07009 "v.io/v23/security/access"
Himabindu Pucha12e1a122015-06-08 15:59:09 -070010)
11
Himabindu Puchafb26a832015-05-20 15:37:50 -070012// Sync defines methods for data exchange between Syncbases.
13// TODO(hpucha): Flesh this out further.
14type Sync interface {
Jatin Lodhia456b81f2015-10-05 17:21:28 -070015 // GetTime returns metadata related to syncbase clock like syncbase clock
16 // timestamps, last NTP timestamp, num reboots, etc.
17 GetTime(req TimeReq, initiator string) (TimeResp | error)
18
Himabindu Pucha03ef3932015-06-26 17:56:09 -070019 // GetDeltas returns the responder's current generation vector and all
20 // the missing log records when compared to the initiator's generation
Himabindu Puchab41fc142015-09-10 17:10:57 -070021 // vector for one Database for either SyncGroup metadata or data.
22 GetDeltas(req DeltaReq, initiator string) stream<_, DeltaResp> error {access.Read}
Himabindu Puchafb26a832015-05-20 15:37:50 -070023
24 // SyncGroup-related methods.
Himabindu Puchafb26a832015-05-20 15:37:50 -070025
Raja Daoud52851362015-09-14 15:50:40 -070026 // PublishSyncGroup is invoked on the SyncGroup name (typically served
27 // by a "central" peer) to publish the SyncGroup. It takes the name of
28 // Syncbase doing the publishing (the publisher) and returns the name
29 // of the Syncbase where the SyncGroup is published (the publishee).
30 // This allows the publisher and the publishee to learn of each other.
31 // When a SyncGroup is published, the publishee is given the SyncGroup
32 // metadata, its current version at the publisher, and the current
33 // SyncGroup generation vector. The generation vector serves as a
34 // checkpoint at the time of publishing. The publishing proceeds
35 // asynchronously, and the publishee learns the SyncGroup history
36 // through the routine p2p sync process and determines when it has
37 // caught up to the level of knowledge at the time of publishing using
38 // the checkpointed generation vector. Until that point, the publishee
39 // locally deems the SyncGroup to be in a pending state and does not
40 // mutate it. Thus it locally rejects SyncGroup joins or updates to
41 // its spec until it is caught up on the SyncGroup history.
42 PublishSyncGroup(publisher string, sg SyncGroup, version string, genvec PrefixGenVector) (string | error) {access.Write}
Himabindu Puchafb26a832015-05-20 15:37:50 -070043
Himabindu Pucha12e1a122015-06-08 15:59:09 -070044 // JoinSyncGroupAtAdmin is invoked by a prospective SyncGroup member's
45 // Syncbase on a SyncGroup admin. It checks whether the requestor is
46 // allowed to join the named SyncGroup, and if so, adds the requestor to
Raja Daoud52851362015-09-14 15:50:40 -070047 // the SyncGroup. It returns a copy of the updated SyncGroup metadata,
48 // its version, and the SyncGroup generation vector at the time of the
49 // join. Similar to the PublishSyncGroup scenario, the joiner at that
50 // point does not have the SyncGroup history and locally deems it to be
51 // in a pending state and does not mutate it. This means it rejects
52 // local updates to the SyncGroup spec or, if it were also an admin on
53 // the SyncGroup, it would reject SyncGroup joins until it is caught up
54 // on the SyncGroup history through p2p sync.
55 JoinSyncGroupAtAdmin(sgName, joinerName string, myInfo wire.SyncGroupMemberInfo) (sg SyncGroup, version string, genvec PrefixGenVector | error) {access.Read}
Himabindu Puchafb26a832015-05-20 15:37:50 -070056
57 // BlobSync methods.
Himabindu Pucha665f14c2015-08-13 13:42:01 -070058
59 // HaveBlob verifies that the peer has the requested blob, and if
60 // present, returns its size.
61 HaveBlob(br wire.BlobRef) (int64 | error)
62
63 // FetchBlob fetches the requested blob.
64 FetchBlob(br wire.BlobRef) stream<_, []byte> error
65
66 // Methods for incremental blob transfer. The transfer starts with the
67 // receiver making a FetchBlobRecipe call to the sender for a given
68 // BlobRef. The sender, in turn, sends the chunk hashes of all the
69 // chunks that make up the requested blob (blob recipe). The receiver
70 // looks up the chunk hashes in its local blob store, and identifies the
71 // missing ones. The receiver then fetches the missing chunks using a
72 // FetchChunks call from the sender. Finally, the receiver finishes the
73 // blob fetch by combining the chunks obtained over the network with the
74 // already available local chunks as per the blob recipe.
75 FetchBlobRecipe(br wire.BlobRef) stream<_, ChunkHash> error
76 FetchChunks() stream<ChunkHash, ChunkData> error
Himabindu Puchafb26a832015-05-20 15:37:50 -070077}
Raja Daoud52851362015-09-14 15:50:40 -070078
79error (
80 DupSyncGroupPublish(name string) {"en": "duplicate publish on SyncGroup: {name}"}
81)