/
syncgroup.go
71 lines (57 loc) · 2.01 KB
/
syncgroup.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// 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
import (
"v.io/v23/context"
wire "v.io/v23/services/syncbase"
)
var (
_ Syncgroup = (*syncgroup)(nil)
)
type syncgroup struct {
c wire.DatabaseClientMethods
id wire.Id
}
func newSyncgroup(dbName string, id wire.Id) Syncgroup {
return &syncgroup{
c: wire.DatabaseClient(dbName),
id: id,
}
}
// Create implements Syncgroup.Create.
func (sg *syncgroup) Create(ctx *context.T, spec wire.SyncgroupSpec, myInfo wire.SyncgroupMemberInfo) error {
return sg.c.CreateSyncgroup(ctx, sg.id, spec, myInfo)
}
// Join implements Syncgroup.Join.
func (sg *syncgroup) Join(ctx *context.T, remoteSyncbaseName string, expectedSyncbaseBlessings []string, myInfo wire.SyncgroupMemberInfo) (wire.SyncgroupSpec, error) {
return sg.c.JoinSyncgroup(ctx, remoteSyncbaseName, expectedSyncbaseBlessings, sg.id, myInfo)
}
// Leave implements Syncgroup.Leave.
func (sg *syncgroup) Leave(ctx *context.T) error {
return sg.c.LeaveSyncgroup(ctx, sg.id)
}
// Destroy implements Syncgroup.Destroy.
func (sg *syncgroup) Destroy(ctx *context.T) error {
return sg.c.DestroySyncgroup(ctx, sg.id)
}
// Eject implements Syncgroup.Eject.
func (sg *syncgroup) Eject(ctx *context.T, member string) error {
return sg.c.EjectFromSyncgroup(ctx, sg.id, member)
}
// GetSpec implements Syncgroup.GetSpec.
func (sg *syncgroup) GetSpec(ctx *context.T) (wire.SyncgroupSpec, string, error) {
return sg.c.GetSyncgroupSpec(ctx, sg.id)
}
// SetSpec implements Syncgroup.SetSpec.
func (sg *syncgroup) SetSpec(ctx *context.T, spec wire.SyncgroupSpec, version string) error {
return sg.c.SetSyncgroupSpec(ctx, sg.id, spec, version)
}
// GetMembers implements Syncgroup.GetMembers.
func (sg *syncgroup) GetMembers(ctx *context.T) (map[string]wire.SyncgroupMemberInfo, error) {
return sg.c.GetSyncgroupMembers(ctx, sg.id)
}
// Id implements Syncgroup.Id.
func (sg *syncgroup) Id() wire.Id {
return sg.id
}