/
test_handler.go
48 lines (40 loc) · 1.2 KB
/
test_handler.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
// Copyright 2015 Keybase, Inc. All rights reserved. Use of
// this source code is governed by the included BSD license.
package service
import (
"github.com/keybase/client/go/libkb"
keybase1 "github.com/keybase/client/go/protocol/keybase1"
"github.com/keybase/go-framed-msgpack-rpc/rpc"
"golang.org/x/net/context"
)
type TestHandler struct {
*BaseHandler
libkb.Contextified
}
func NewTestHandler(xp rpc.Transporter, g *libkb.GlobalContext) *TestHandler {
return &TestHandler{
BaseHandler: NewBaseHandler(g, xp),
Contextified: libkb.NewContextified(g),
}
}
func (t TestHandler) Test(ctx context.Context, arg keybase1.TestArg) (test keybase1.Test, err error) {
client := t.rpcClient()
cbArg := keybase1.TestCallbackArg{Name: arg.Name, SessionID: arg.SessionID}
var cbReply string
err = client.Call(ctx, "keybase.1.test.testCallback", []interface{}{cbArg}, &cbReply)
if err != nil {
return
}
test.Reply = cbReply
return
}
func (t TestHandler) TestCallback(_ context.Context, arg keybase1.TestCallbackArg) (s string, err error) {
return
}
func (t TestHandler) Panic(_ context.Context, message string) error {
t.G().Log.Info("Received panic() RPC")
go func() {
panic(message)
}()
return nil
}