Skip to content

Commit

Permalink
chore(proto): Update thrift
Browse files Browse the repository at this point in the history
Change-Id: Ia20e1ba6712055658db7f7ebe04da7d66d0e8862
  • Loading branch information
andeya committed Jun 25, 2019
1 parent 5951dbb commit ae46fa0
Show file tree
Hide file tree
Showing 8 changed files with 333 additions and 309 deletions.
32 changes: 10 additions & 22 deletions proto/thriftproto/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,55 +35,43 @@ type Home struct {
tp.CallCtx
}

func (h *Home) Test(arg *map[string]string) (map[string]interface{}, *tp.Rerror) {
h.Session().Push("Push.Test", map[string]string{
"your_id": string(h.PeekMeta("peer_id")),
})
return map[string]interface{}{
"arg": *arg,
func (h *Home) Test(arg *thriftproto.Test) (*thriftproto.Test, *tp.Rerror) {
return &thriftproto.Test{
Author: arg.Author + "->OK",
}, nil
}

func TestTProto(t *testing.T) {
gzip.Reg('g', "gizp-5", 5)

// server
srv := tp.NewPeer(tp.PeerConfig{ListenPort: 9090})
srv := tp.NewPeer(tp.PeerConfig{ListenPort: 9090, DefaultBodyCodec: "thrift"})
srv.RouteCall(new(Home))
go srv.ListenAndServe(thriftproto.NewTProtoFunc(nil, nil))
time.Sleep(1e9)

// client
cli := tp.NewPeer(tp.PeerConfig{})
cli.RoutePush(new(Push))
cli := tp.NewPeer(tp.PeerConfig{DefaultBodyCodec: "thrift"})
sess, err := cli.Dial(":9090", thriftproto.NewTProtoFunc(nil, nil))
if err != nil {
t.Error(err)
}
var result interface{}
var result thriftproto.Test
rerr := sess.Call("Home.Test",
map[string]string{
"author": "henrylee2cn",
},
&thriftproto.Test{Author: "henrylee2cn"},
&result,
tp.WithAddMeta("peer_id", "110"),
tp.WithXferPipe('g'),
).Rerror()
if rerr != nil {
t.Error(rerr)
}
if result.Author != "henrylee2cn->OK" {
t.FailNow()
}
t.Logf("result:%v", result)
time.Sleep(2e9)
}

type Push struct {
tp.PushCtx
}

func (p *Push) Test(arg *map[string]string) *tp.Rerror {
tp.Infof("receive push(%s):\narg: %#v\n", p.IP(), arg)
return nil
}
```

test command:
Expand Down
7 changes: 0 additions & 7 deletions proto/thriftproto/gen-go/payload/GoUnusedProtection__.go

This file was deleted.

24 changes: 0 additions & 24 deletions proto/thriftproto/gen-go/payload/payload-consts.go

This file was deleted.

219 changes: 0 additions & 219 deletions proto/thriftproto/gen-go/payload/payload.go

This file was deleted.

18 changes: 10 additions & 8 deletions proto/thriftproto/payload.thrift
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
namespace go payload
namespace perl payload
namespace py payload
namespace cpp payload
namespace rb payload
namespace java payload

// thrift-0.11.0
namespace go thriftproto
namespace perl thriftproto
namespace py thriftproto
namespace cpp thriftproto
namespace rb thriftproto
namespace java thriftproto

struct payload {
1: binary meta,
2: binary xferPipe,
3: i32 bodyCodec,
4: binary body
}

struct test {
1: string author,
}
Loading

0 comments on commit ae46fa0

Please sign in to comment.