Skip to content

Commit

Permalink
Fix proto case issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
cscatolini committed Jun 4, 2018
1 parent f929854 commit 095a4e3
Show file tree
Hide file tree
Showing 11 changed files with 106 additions and 105 deletions.
2 changes: 1 addition & 1 deletion agent/agent_remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (a *Remote) Kick(ctx context.Context) error {
return constants.ErrNoUIDBind
}
b, err := proto.Marshal(&protos.KickMsg{
UserID: a.Session.UID(),
UserId: a.Session.UID(),
})
if err != nil {
return err
Expand Down
20 changes: 10 additions & 10 deletions e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ func TestHandlerCallToFront(t *testing.T) {
data []byte
resp []byte
}{
{"connector.testsvc.testrequestonlysessionreturnsptr", []byte(``), []byte(`{"Code":200,"Msg":"hello"}`)},
{"connector.testsvc.testrequestonlysessionreturnsptr", []byte(``), []byte(`{"code":200,"msg":"hello"}`)},
{"connector.testsvc.testrequestonlysessionreturnsptrnil", []byte(``), []byte(`{"code":"PIT-000","msg":"reply must not be null"}`)},
{"connector.testsvc.testrequestonlysessionreturnsrawnil", []byte(``), []byte(`{"code":"PIT-000","msg":"reply must not be null"}`)},
{"connector.testsvc.testrequestreturnsptr", []byte(`{"msg":"good"}`), []byte(`{"Code":200,"Msg":"good"}`)},
{"connector.testsvc.testrequestreturnsptr", []byte(`{"msg":"good"}`), []byte(`{"code":200,"msg":"good"}`)},
{"connector.testsvc.testrequestreturnsraw", []byte(`{"msg":"good"}`), []byte(`good`)},
{"connector.testsvc.testrequestreceivereturnsraw", []byte(`woow`), []byte(`woow`)},
{"connector.testsvc.nonexistenthandler", []byte(`woow`), []byte(`{"code":"PIT-404","msg":"pitaya/handler: connector.testsvc.nonexistenthandler not found"}`)},
Expand Down Expand Up @@ -120,7 +120,7 @@ func TestGroupFront(t *testing.T) {
data []byte
}{
{"connector.testsvc.testsendgroupmsg", []byte("testing group")},
{"connector.testsvc.testsendgroupmsgptr", []byte(`{"Msg":"hellow"}`)},
{"connector.testsvc.testsendgroupmsgptr", []byte(`{"msg":"hellow"}`)},
}

for _, table := range tables {
Expand Down Expand Up @@ -357,8 +357,8 @@ func TestForwardToBackend(t *testing.T) {
data []byte
resp []byte
}{
{"game.testsvc.testrequestonlysessionreturnsptr", []byte(``), []byte(`{"Code":200,"Msg":"hello"}`)},
{"game.testsvc.testrequestreturnsptr", []byte(`{"msg":"good"}`), []byte(`{"Code":200,"Msg":"good"}`)},
{"game.testsvc.testrequestonlysessionreturnsptr", []byte(``), []byte(`{"code":200,"msg":"hello"}`)},
{"game.testsvc.testrequestreturnsptr", []byte(`{"msg":"good"}`), []byte(`{"code":200,"msg":"good"}`)},
{"game.testsvc.testrequestreturnsraw", []byte(`{"msg":"good"}`), []byte(`good`)},
{"game.testsvc.testrequestreceivereturnsraw", []byte(`woow`), []byte(`woow`)},
{"game.testsvc.nonexistenthandler", []byte(`woow`), []byte(`{"code":"PIT-404","msg":"pitaya/handler: game.testsvc.nonexistenthandler not found"}`)},
Expand Down Expand Up @@ -418,7 +418,7 @@ func TestGroupBack(t *testing.T) {
data []byte
}{
{"game.testsvc.testsendgroupmsg", []byte("testing group")},
{"game.testsvc.testsendgroupmsgptr", []byte(`{"Msg":"hellow"}`)},
{"game.testsvc.testsendgroupmsgptr", []byte(`{"msg":"hellow"}`)},
}

for _, table := range tables {
Expand Down Expand Up @@ -452,13 +452,13 @@ func TestUserRPC(t *testing.T) {
data []byte
res []byte
}{
{"front_to_back", "connector.testsvc.testsendrpc", []byte(`{"route":"game.testremotesvc.rpctestrawptrreturnsptr","data":"thisthis"}`), []byte(`{"Code":200,"Msg":"got thisthis"}`)},
{"back_to_front", "game.testsvc.testsendrpc", []byte(`{"route":"connector.testremotesvc.rpctestrawptrreturnsptr","data":"thisthis"}`), []byte(`{"Code":200,"Msg":"got thisthis"}`)},
{"front_to_back", "connector.testsvc.testsendrpc", []byte(`{"route":"game.testremotesvc.rpctestrawptrreturnsptr","data":"thisthis"}`), []byte(`{"code":200,"msg":"got thisthis"}`)},
{"back_to_front", "game.testsvc.testsendrpc", []byte(`{"route":"connector.testremotesvc.rpctestrawptrreturnsptr","data":"thisthis"}`), []byte(`{"code":200,"msg":"got thisthis"}`)},
{"front_to_back_error", "connector.testsvc.testsendrpc", []byte(`{"route":"game.testremotesvc.rpctestreturnserror","data":"thisthis"}`), []byte(`{"code":"PIT-433","msg":"test error","metadata":{"some":"meta"}}`)},
{"back_to_front_error", "game.testsvc.testsendrpc", []byte(`{"route":"connector.testremotesvc.rpctestreturnserror","data":"thisthis"}`), []byte(`{"code":"PIT-433","msg":"test error","metadata":{"some":"meta"}}`)},
{"same_server", "connector.testsvc.testsendrpc", []byte(`{"route":"connector.testremotesvc.rpctestrawptrreturnsptr","data":"thisthis"}`), []byte(`{"code":"PIT-000","msg":"you are making a rpc that may be processed locally, either specify a different server type or specify a server id"}`)},
{"front_to_back_ptr", "connector.testsvc.testsendrpc", []byte(`{"route":"game.testremotesvc.rpctestptrreturnsptr","data":"thisthis"}`), []byte(`{"Code":200,"Msg":"got thisthis"}`)},
{"no_args", "connector.testsvc.testsendrpcnoargs", []byte(`{"route":"game.testremotesvc.rpctestnoargs"}`), []byte(`{"Code":200,"Msg":"got nothing"}`)},
{"front_to_back_ptr", "connector.testsvc.testsendrpc", []byte(`{"route":"game.testremotesvc.rpctestptrreturnsptr","data":"thisthis"}`), []byte(`{"code":200,"msg":"got thisthis"}`)},
{"no_args", "connector.testsvc.testsendrpcnoargs", []byte(`{"route":"game.testremotesvc.rpctestnoargs"}`), []byte(`{"code":200,"msg":"got nothing"}`)},
{"not_found", "connector.testsvc.testsendrpc", []byte(`{"route":"game.testremotesvc.rpctestnotfound","data":"thisthis"}`), []byte(`{"code":"PIT-404","msg":"route not found","metadata":{"route":"testremotesvc.rpctestnotfound"}}`)},
}

Expand Down
12 changes: 6 additions & 6 deletions examples/testing/protos/cluster.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions examples/testing/protos/cluster.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ package protos;

// TestRequest message to be sent using rpc
message TestRequest {
string Msg = 1;
string msg = 1;
}

// TestResponse is the rpc response
message TestResponse {
int32 Code = 1;
string Msg = 2;
int32 code = 1;
string msg = 2;
}
8 changes: 4 additions & 4 deletions modules/unique_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ func (u *UniqueSession) processBindings(bindingsChan chan *nats.Msg) {
if err != nil {
continue
}
if u.server.ID == msg.FID {
if u.server.ID == msg.Fid {
continue
}
oldSession := session.GetSessionByUID(msg.UID)
oldSession := session.GetSessionByUID(msg.Uid)
if oldSession != nil {
// TODO it would be nice to set this correctly
oldSession.Kick(context.Background())
Expand All @@ -84,8 +84,8 @@ func (u *UniqueSession) Init() error {
return oldSession.Kick(ctx)
}
msg := &protos.BindMsg{
UID: s.UID(),
FID: u.server.ID,
Uid: s.UID(),
Fid: u.server.ID,
}
msgData, err := proto.Marshal(msg)
if err != nil {
Expand Down
Loading

0 comments on commit 095a4e3

Please sign in to comment.