github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/protocol/gregor1/incoming.go (about) 1 // Auto-generated to Go types and interfaces using avdl-compiler v1.4.10 (https://github.com/keybase/node-avdl-compiler) 2 // Input file: avdl/gregor1/incoming.avdl 3 4 package gregor1 5 6 import ( 7 "github.com/keybase/go-framed-msgpack-rpc/rpc" 8 context "golang.org/x/net/context" 9 "time" 10 ) 11 12 type SyncResult struct { 13 Msgs []InBandMessage `codec:"msgs" json:"msgs"` 14 Hash []byte `codec:"hash" json:"hash"` 15 } 16 17 func (o SyncResult) DeepCopy() SyncResult { 18 return SyncResult{ 19 Msgs: (func(x []InBandMessage) []InBandMessage { 20 if x == nil { 21 return nil 22 } 23 ret := make([]InBandMessage, len(x)) 24 for i, v := range x { 25 vCopy := v.DeepCopy() 26 ret[i] = vCopy 27 } 28 return ret 29 })(o.Msgs), 30 Hash: (func(x []byte) []byte { 31 if x == nil { 32 return nil 33 } 34 return append([]byte{}, x...) 35 })(o.Hash), 36 } 37 } 38 39 // DescribeConnectedUsers will take a list of users, and return the list of users 40 // which are connected to any Gregor in the cluster, and what devices (and device type) 41 // those users are connected with. 42 type ConnectedDevice struct { 43 DeviceID DeviceID `codec:"deviceID" json:"deviceID"` 44 DeviceType string `codec:"deviceType" json:"deviceType"` 45 DevicePlatform string `codec:"devicePlatform" json:"devicePlatform"` 46 UserAgent string `codec:"userAgent" json:"userAgent"` 47 } 48 49 func (o ConnectedDevice) DeepCopy() ConnectedDevice { 50 return ConnectedDevice{ 51 DeviceID: o.DeviceID.DeepCopy(), 52 DeviceType: o.DeviceType, 53 DevicePlatform: o.DevicePlatform, 54 UserAgent: o.UserAgent, 55 } 56 } 57 58 type ConnectedUser struct { 59 Uid UID `codec:"uid" json:"uid"` 60 Devices []ConnectedDevice `codec:"devices" json:"devices"` 61 } 62 63 func (o ConnectedUser) DeepCopy() ConnectedUser { 64 return ConnectedUser{ 65 Uid: o.Uid.DeepCopy(), 66 Devices: (func(x []ConnectedDevice) []ConnectedDevice { 67 if x == nil { 68 return nil 69 } 70 ret := make([]ConnectedDevice, len(x)) 71 for i, v := range x { 72 vCopy := v.DeepCopy() 73 ret[i] = vCopy 74 } 75 return ret 76 })(o.Devices), 77 } 78 } 79 80 type SyncArg struct { 81 Uid UID `codec:"uid" json:"uid"` 82 Deviceid DeviceID `codec:"deviceid" json:"deviceid"` 83 Ctime Time `codec:"ctime" json:"ctime"` 84 } 85 86 type ConsumeMessageArg struct { 87 M Message `codec:"m" json:"m"` 88 } 89 90 type ConsumePublishMessageArg struct { 91 M Message `codec:"m" json:"m"` 92 } 93 94 type ConsumeMessageMultiArg struct { 95 Msg Message `codec:"msg" json:"msg"` 96 Uids []UID `codec:"uids" json:"uids"` 97 } 98 99 type PingArg struct { 100 } 101 102 type VersionArg struct { 103 Uid UID `codec:"uid" json:"uid"` 104 } 105 106 type StateArg struct { 107 Uid UID `codec:"uid" json:"uid"` 108 Deviceid DeviceID `codec:"deviceid" json:"deviceid"` 109 TimeOrOffset TimeOrOffset `codec:"timeOrOffset" json:"timeOrOffset"` 110 } 111 112 type StateByCategoryPrefixArg struct { 113 Uid UID `codec:"uid" json:"uid"` 114 Deviceid DeviceID `codec:"deviceid" json:"deviceid"` 115 TimeOrOffset TimeOrOffset `codec:"timeOrOffset" json:"timeOrOffset"` 116 CategoryPrefix Category `codec:"categoryPrefix" json:"categoryPrefix"` 117 } 118 119 type DescribeConnectedUsersArg struct { 120 Uids []UID `codec:"uids" json:"uids"` 121 } 122 123 type DescribeConnectedUsersInternalArg struct { 124 Uids []UID `codec:"uids" json:"uids"` 125 } 126 127 type IncomingInterface interface { 128 Sync(context.Context, SyncArg) (SyncResult, error) 129 ConsumeMessage(context.Context, Message) error 130 ConsumePublishMessage(context.Context, Message) error 131 // consumeMessageMulti will take msg and consume it for all the users listed 132 // in uids. This is so a gregor client can send the same message to many UIDs 133 // with one call, as opposed to calling consumeMessage for each UID. 134 ConsumeMessageMulti(context.Context, ConsumeMessageMultiArg) error 135 Ping(context.Context) (string, error) 136 Version(context.Context, UID) (string, error) 137 State(context.Context, StateArg) (State, error) 138 // StateByCategoryPrefix loads the messages of the user's state whose 139 // categories are prefixed by the given prefix 140 StateByCategoryPrefix(context.Context, StateByCategoryPrefixArg) (State, error) 141 DescribeConnectedUsers(context.Context, []UID) ([]ConnectedUser, error) 142 DescribeConnectedUsersInternal(context.Context, []UID) ([]ConnectedUser, error) 143 } 144 145 func IncomingProtocol(i IncomingInterface) rpc.Protocol { 146 return rpc.Protocol{ 147 Name: "gregor.1.incoming", 148 Methods: map[string]rpc.ServeHandlerDescription{ 149 "sync": { 150 MakeArg: func() interface{} { 151 var ret [1]SyncArg 152 return &ret 153 }, 154 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 155 typedArgs, ok := args.(*[1]SyncArg) 156 if !ok { 157 err = rpc.NewTypeError((*[1]SyncArg)(nil), args) 158 return 159 } 160 ret, err = i.Sync(ctx, typedArgs[0]) 161 return 162 }, 163 }, 164 "consumeMessage": { 165 MakeArg: func() interface{} { 166 var ret [1]ConsumeMessageArg 167 return &ret 168 }, 169 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 170 typedArgs, ok := args.(*[1]ConsumeMessageArg) 171 if !ok { 172 err = rpc.NewTypeError((*[1]ConsumeMessageArg)(nil), args) 173 return 174 } 175 err = i.ConsumeMessage(ctx, typedArgs[0].M) 176 return 177 }, 178 }, 179 "consumePublishMessage": { 180 MakeArg: func() interface{} { 181 var ret [1]ConsumePublishMessageArg 182 return &ret 183 }, 184 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 185 typedArgs, ok := args.(*[1]ConsumePublishMessageArg) 186 if !ok { 187 err = rpc.NewTypeError((*[1]ConsumePublishMessageArg)(nil), args) 188 return 189 } 190 err = i.ConsumePublishMessage(ctx, typedArgs[0].M) 191 return 192 }, 193 }, 194 "consumeMessageMulti": { 195 MakeArg: func() interface{} { 196 var ret [1]ConsumeMessageMultiArg 197 return &ret 198 }, 199 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 200 typedArgs, ok := args.(*[1]ConsumeMessageMultiArg) 201 if !ok { 202 err = rpc.NewTypeError((*[1]ConsumeMessageMultiArg)(nil), args) 203 return 204 } 205 err = i.ConsumeMessageMulti(ctx, typedArgs[0]) 206 return 207 }, 208 }, 209 "ping": { 210 MakeArg: func() interface{} { 211 var ret [1]PingArg 212 return &ret 213 }, 214 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 215 ret, err = i.Ping(ctx) 216 return 217 }, 218 }, 219 "version": { 220 MakeArg: func() interface{} { 221 var ret [1]VersionArg 222 return &ret 223 }, 224 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 225 typedArgs, ok := args.(*[1]VersionArg) 226 if !ok { 227 err = rpc.NewTypeError((*[1]VersionArg)(nil), args) 228 return 229 } 230 ret, err = i.Version(ctx, typedArgs[0].Uid) 231 return 232 }, 233 }, 234 "state": { 235 MakeArg: func() interface{} { 236 var ret [1]StateArg 237 return &ret 238 }, 239 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 240 typedArgs, ok := args.(*[1]StateArg) 241 if !ok { 242 err = rpc.NewTypeError((*[1]StateArg)(nil), args) 243 return 244 } 245 ret, err = i.State(ctx, typedArgs[0]) 246 return 247 }, 248 }, 249 "stateByCategoryPrefix": { 250 MakeArg: func() interface{} { 251 var ret [1]StateByCategoryPrefixArg 252 return &ret 253 }, 254 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 255 typedArgs, ok := args.(*[1]StateByCategoryPrefixArg) 256 if !ok { 257 err = rpc.NewTypeError((*[1]StateByCategoryPrefixArg)(nil), args) 258 return 259 } 260 ret, err = i.StateByCategoryPrefix(ctx, typedArgs[0]) 261 return 262 }, 263 }, 264 "describeConnectedUsers": { 265 MakeArg: func() interface{} { 266 var ret [1]DescribeConnectedUsersArg 267 return &ret 268 }, 269 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 270 typedArgs, ok := args.(*[1]DescribeConnectedUsersArg) 271 if !ok { 272 err = rpc.NewTypeError((*[1]DescribeConnectedUsersArg)(nil), args) 273 return 274 } 275 ret, err = i.DescribeConnectedUsers(ctx, typedArgs[0].Uids) 276 return 277 }, 278 }, 279 "describeConnectedUsersInternal": { 280 MakeArg: func() interface{} { 281 var ret [1]DescribeConnectedUsersInternalArg 282 return &ret 283 }, 284 Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) { 285 typedArgs, ok := args.(*[1]DescribeConnectedUsersInternalArg) 286 if !ok { 287 err = rpc.NewTypeError((*[1]DescribeConnectedUsersInternalArg)(nil), args) 288 return 289 } 290 ret, err = i.DescribeConnectedUsersInternal(ctx, typedArgs[0].Uids) 291 return 292 }, 293 }, 294 }, 295 } 296 } 297 298 type IncomingClient struct { 299 Cli rpc.GenericClient 300 } 301 302 func (c IncomingClient) Sync(ctx context.Context, __arg SyncArg) (res SyncResult, err error) { 303 err = c.Cli.CallCompressed(ctx, "gregor.1.incoming.sync", []interface{}{__arg}, &res, rpc.CompressionGzip, 0*time.Millisecond) 304 return 305 } 306 307 func (c IncomingClient) ConsumeMessage(ctx context.Context, m Message) (err error) { 308 __arg := ConsumeMessageArg{M: m} 309 err = c.Cli.CallCompressed(ctx, "gregor.1.incoming.consumeMessage", []interface{}{__arg}, nil, rpc.CompressionGzip, 0*time.Millisecond) 310 return 311 } 312 313 func (c IncomingClient) ConsumePublishMessage(ctx context.Context, m Message) (err error) { 314 __arg := ConsumePublishMessageArg{M: m} 315 err = c.Cli.CallCompressed(ctx, "gregor.1.incoming.consumePublishMessage", []interface{}{__arg}, nil, rpc.CompressionGzip, 0*time.Millisecond) 316 return 317 } 318 319 // consumeMessageMulti will take msg and consume it for all the users listed 320 // in uids. This is so a gregor client can send the same message to many UIDs 321 // with one call, as opposed to calling consumeMessage for each UID. 322 func (c IncomingClient) ConsumeMessageMulti(ctx context.Context, __arg ConsumeMessageMultiArg) (err error) { 323 err = c.Cli.CallCompressed(ctx, "gregor.1.incoming.consumeMessageMulti", []interface{}{__arg}, nil, rpc.CompressionGzip, 0*time.Millisecond) 324 return 325 } 326 327 func (c IncomingClient) Ping(ctx context.Context) (res string, err error) { 328 err = c.Cli.Call(ctx, "gregor.1.incoming.ping", []interface{}{PingArg{}}, &res, 0*time.Millisecond) 329 return 330 } 331 332 func (c IncomingClient) Version(ctx context.Context, uid UID) (res string, err error) { 333 __arg := VersionArg{Uid: uid} 334 err = c.Cli.CallCompressed(ctx, "gregor.1.incoming.version", []interface{}{__arg}, &res, rpc.CompressionGzip, 0*time.Millisecond) 335 return 336 } 337 338 func (c IncomingClient) State(ctx context.Context, __arg StateArg) (res State, err error) { 339 err = c.Cli.CallCompressed(ctx, "gregor.1.incoming.state", []interface{}{__arg}, &res, rpc.CompressionGzip, 0*time.Millisecond) 340 return 341 } 342 343 // StateByCategoryPrefix loads the messages of the user's state whose 344 // categories are prefixed by the given prefix 345 func (c IncomingClient) StateByCategoryPrefix(ctx context.Context, __arg StateByCategoryPrefixArg) (res State, err error) { 346 err = c.Cli.CallCompressed(ctx, "gregor.1.incoming.stateByCategoryPrefix", []interface{}{__arg}, &res, rpc.CompressionGzip, 0*time.Millisecond) 347 return 348 } 349 350 func (c IncomingClient) DescribeConnectedUsers(ctx context.Context, uids []UID) (res []ConnectedUser, err error) { 351 __arg := DescribeConnectedUsersArg{Uids: uids} 352 err = c.Cli.CallCompressed(ctx, "gregor.1.incoming.describeConnectedUsers", []interface{}{__arg}, &res, rpc.CompressionGzip, 0*time.Millisecond) 353 return 354 } 355 356 func (c IncomingClient) DescribeConnectedUsersInternal(ctx context.Context, uids []UID) (res []ConnectedUser, err error) { 357 __arg := DescribeConnectedUsersInternalArg{Uids: uids} 358 err = c.Cli.CallCompressed(ctx, "gregor.1.incoming.describeConnectedUsersInternal", []interface{}{__arg}, &res, rpc.CompressionGzip, 0*time.Millisecond) 359 return 360 }