/
sserver.go
201 lines (182 loc) · 6.04 KB
/
sserver.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
// Auto-generated by avdl-compiler v1.3.1 (https://github.com/keybase/node-avdl-compiler)
// Input file: sserver-avdl/sserver.avdl
package searchsrv1
import (
rpc "github.com/keybase/go-framed-msgpack-rpc"
context "golang.org/x/net/context"
)
type DocumentID string
type FolderID string
type TlfInfo struct {
Salts [][]byte `codec:"salts" json:"salts"`
Size int64 `codec:"size" json:"size"`
}
type Trapdoor struct {
Codeword [][]byte `codec:"codeword" json:"codeword"`
}
type WriteIndexArg struct {
TlfID FolderID `codec:"tlfID" json:"tlfID"`
SecureIndex []byte `codec:"secureIndex" json:"secureIndex"`
DocID DocumentID `codec:"docID" json:"docID"`
}
type RenameIndexArg struct {
TlfID FolderID `codec:"tlfID" json:"tlfID"`
Orig DocumentID `codec:"orig" json:"orig"`
Curr DocumentID `codec:"curr" json:"curr"`
}
type DeleteIndexArg struct {
TlfID FolderID `codec:"tlfID" json:"tlfID"`
DocID DocumentID `codec:"docID" json:"docID"`
}
type GetKeyGensArg struct {
TlfID FolderID `codec:"tlfID" json:"tlfID"`
}
type SearchWordArg struct {
TlfID FolderID `codec:"tlfID" json:"tlfID"`
Trapdoors map[string]Trapdoor `codec:"trapdoors" json:"trapdoors"`
}
type RegisterTlfIfNotExistsArg struct {
TlfID FolderID `codec:"tlfID" json:"tlfID"`
LenSalt int `codec:"lenSalt" json:"lenSalt"`
FpRate float64 `codec:"fpRate" json:"fpRate"`
NumUniqWords int64 `codec:"numUniqWords" json:"numUniqWords"`
}
type SearchServerInterface interface {
WriteIndex(context.Context, WriteIndexArg) error
RenameIndex(context.Context, RenameIndexArg) error
DeleteIndex(context.Context, DeleteIndexArg) error
GetKeyGens(context.Context, FolderID) ([]int, error)
SearchWord(context.Context, SearchWordArg) ([]DocumentID, error)
RegisterTlfIfNotExists(context.Context, RegisterTlfIfNotExistsArg) (TlfInfo, error)
}
func SearchServerProtocol(i SearchServerInterface) rpc.Protocol {
return rpc.Protocol{
Name: "searchsrv.1.searchServer",
Methods: map[string]rpc.ServeHandlerDescription{
"writeIndex": {
MakeArg: func() interface{} {
ret := make([]WriteIndexArg, 1)
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[]WriteIndexArg)
if !ok {
err = rpc.NewTypeError((*[]WriteIndexArg)(nil), args)
return
}
err = i.WriteIndex(ctx, (*typedArgs)[0])
return
},
MethodType: rpc.MethodCall,
},
"renameIndex": {
MakeArg: func() interface{} {
ret := make([]RenameIndexArg, 1)
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[]RenameIndexArg)
if !ok {
err = rpc.NewTypeError((*[]RenameIndexArg)(nil), args)
return
}
err = i.RenameIndex(ctx, (*typedArgs)[0])
return
},
MethodType: rpc.MethodCall,
},
"deleteIndex": {
MakeArg: func() interface{} {
ret := make([]DeleteIndexArg, 1)
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[]DeleteIndexArg)
if !ok {
err = rpc.NewTypeError((*[]DeleteIndexArg)(nil), args)
return
}
err = i.DeleteIndex(ctx, (*typedArgs)[0])
return
},
MethodType: rpc.MethodCall,
},
"getKeyGens": {
MakeArg: func() interface{} {
ret := make([]GetKeyGensArg, 1)
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[]GetKeyGensArg)
if !ok {
err = rpc.NewTypeError((*[]GetKeyGensArg)(nil), args)
return
}
ret, err = i.GetKeyGens(ctx, (*typedArgs)[0].TlfID)
return
},
MethodType: rpc.MethodCall,
},
"searchWord": {
MakeArg: func() interface{} {
ret := make([]SearchWordArg, 1)
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[]SearchWordArg)
if !ok {
err = rpc.NewTypeError((*[]SearchWordArg)(nil), args)
return
}
ret, err = i.SearchWord(ctx, (*typedArgs)[0])
return
},
MethodType: rpc.MethodCall,
},
"registerTlfIfNotExists": {
MakeArg: func() interface{} {
ret := make([]RegisterTlfIfNotExistsArg, 1)
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[]RegisterTlfIfNotExistsArg)
if !ok {
err = rpc.NewTypeError((*[]RegisterTlfIfNotExistsArg)(nil), args)
return
}
ret, err = i.RegisterTlfIfNotExists(ctx, (*typedArgs)[0])
return
},
MethodType: rpc.MethodCall,
},
},
}
}
type SearchServerClient struct {
Cli rpc.GenericClient
}
func (c SearchServerClient) WriteIndex(ctx context.Context, __arg WriteIndexArg) (err error) {
err = c.Cli.Call(ctx, "searchsrv.1.searchServer.writeIndex", []interface{}{__arg}, nil)
return
}
func (c SearchServerClient) RenameIndex(ctx context.Context, __arg RenameIndexArg) (err error) {
err = c.Cli.Call(ctx, "searchsrv.1.searchServer.renameIndex", []interface{}{__arg}, nil)
return
}
func (c SearchServerClient) DeleteIndex(ctx context.Context, __arg DeleteIndexArg) (err error) {
err = c.Cli.Call(ctx, "searchsrv.1.searchServer.deleteIndex", []interface{}{__arg}, nil)
return
}
func (c SearchServerClient) GetKeyGens(ctx context.Context, tlfID FolderID) (res []int, err error) {
__arg := GetKeyGensArg{TlfID: tlfID}
err = c.Cli.Call(ctx, "searchsrv.1.searchServer.getKeyGens", []interface{}{__arg}, &res)
return
}
func (c SearchServerClient) SearchWord(ctx context.Context, __arg SearchWordArg) (res []DocumentID, err error) {
err = c.Cli.Call(ctx, "searchsrv.1.searchServer.searchWord", []interface{}{__arg}, &res)
return
}
func (c SearchServerClient) RegisterTlfIfNotExists(ctx context.Context, __arg RegisterTlfIfNotExistsArg) (res TlfInfo, err error) {
err = c.Cli.Call(ctx, "searchsrv.1.searchServer.registerTlfIfNotExists", []interface{}{__arg}, &res)
return
}