Skip to content

Commit

Permalink
Fix decoding of Grpc-Message
Browse files Browse the repository at this point in the history
  • Loading branch information
ishitatsuyuki committed Apr 3, 2018
1 parent e695aee commit 968eb3f
Show file tree
Hide file tree
Showing 9 changed files with 157 additions and 84 deletions.
103 changes: 53 additions & 50 deletions test/go/_proto/improbable/grpcweb/test/test.pb.go

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

6 changes: 5 additions & 1 deletion test/go/testserver/testserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,11 @@ func (s *testSrv) PingError(ctx context.Context, ping *testproto.PingRequest) (*
if ping.GetSendTrailers() {
grpc.SetTrailer(ctx, metadata.Pairs("TrailerTestKey1", "ServerValue1", "TrailerTestKey2", "ServerValue2"))
}
return nil, grpc.Errorf(codes.Code(ping.ErrorCodeReturned), "Intentionally returning error for PingError")
if ping.FailureType == testproto.PingRequest_CODE {
return nil, grpc.Errorf(codes.Code(ping.ErrorCodeReturned), "Intentionally returning error for PingError")
} else {
return nil, grpc.Errorf(codes.Code(ping.ErrorCodeReturned), "💣")
}
}

func (s *testSrv) ContinueStream(ctx context.Context, req *testproto.ContinueStreamRequest) (*google_protobuf.Empty, error) {
Expand Down
1 change: 1 addition & 0 deletions test/proto/improbable/grpcweb/test/test.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ message PingRequest {
NONE = 0;
CODE = 1;
DROP = 2;
CODE_UNICODE = 3;
}

string value = 1;
Expand Down
1 change: 1 addition & 0 deletions test/ts/_proto/improbable/grpcweb/test/test_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export namespace PingRequest {
NONE = 0,
CODE = 1,
DROP = 2,
CODE_UNICODE = 3,
}
}

Expand Down
35 changes: 18 additions & 17 deletions test/ts/_proto/improbable/grpcweb/test/test_pb.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ proto.improbable.grpcweb.test.PingRequest.serializeBinaryToWriter = function(mes
proto.improbable.grpcweb.test.PingRequest.FailureType = {
NONE: 0,
CODE: 1,
DROP: 2
DROP: 2,
CODE_UNICODE: 3
};

/**
Expand All @@ -250,7 +251,7 @@ proto.improbable.grpcweb.test.PingRequest.prototype.getValue = function() {

/** @param {string} value */
proto.improbable.grpcweb.test.PingRequest.prototype.setValue = function(value) {
jspb.Message.setField(this, 1, value);
jspb.Message.setProto3StringField(this, 1, value);
};


Expand All @@ -265,7 +266,7 @@ proto.improbable.grpcweb.test.PingRequest.prototype.getResponseCount = function(

/** @param {number} value */
proto.improbable.grpcweb.test.PingRequest.prototype.setResponseCount = function(value) {
jspb.Message.setField(this, 2, value);
jspb.Message.setProto3IntField(this, 2, value);
};


Expand All @@ -280,7 +281,7 @@ proto.improbable.grpcweb.test.PingRequest.prototype.getErrorCodeReturned = funct

/** @param {number} value */
proto.improbable.grpcweb.test.PingRequest.prototype.setErrorCodeReturned = function(value) {
jspb.Message.setField(this, 3, value);
jspb.Message.setProto3IntField(this, 3, value);
};


Expand All @@ -295,7 +296,7 @@ proto.improbable.grpcweb.test.PingRequest.prototype.getFailureType = function()

/** @param {!proto.improbable.grpcweb.test.PingRequest.FailureType} value */
proto.improbable.grpcweb.test.PingRequest.prototype.setFailureType = function(value) {
jspb.Message.setField(this, 4, value);
jspb.Message.setProto3EnumField(this, 4, value);
};


Expand All @@ -312,7 +313,7 @@ proto.improbable.grpcweb.test.PingRequest.prototype.getCheckMetadata = function(

/** @param {boolean} value */
proto.improbable.grpcweb.test.PingRequest.prototype.setCheckMetadata = function(value) {
jspb.Message.setField(this, 5, value);
jspb.Message.setProto3BooleanField(this, 5, value);
};


Expand All @@ -329,7 +330,7 @@ proto.improbable.grpcweb.test.PingRequest.prototype.getSendHeaders = function()

/** @param {boolean} value */
proto.improbable.grpcweb.test.PingRequest.prototype.setSendHeaders = function(value) {
jspb.Message.setField(this, 6, value);
jspb.Message.setProto3BooleanField(this, 6, value);
};


Expand All @@ -346,7 +347,7 @@ proto.improbable.grpcweb.test.PingRequest.prototype.getSendTrailers = function()

/** @param {boolean} value */
proto.improbable.grpcweb.test.PingRequest.prototype.setSendTrailers = function(value) {
jspb.Message.setField(this, 7, value);
jspb.Message.setProto3BooleanField(this, 7, value);
};


Expand All @@ -361,7 +362,7 @@ proto.improbable.grpcweb.test.PingRequest.prototype.getStreamIdentifier = functi

/** @param {string} value */
proto.improbable.grpcweb.test.PingRequest.prototype.setStreamIdentifier = function(value) {
jspb.Message.setField(this, 8, value);
jspb.Message.setProto3StringField(this, 8, value);
};


Expand Down Expand Up @@ -515,7 +516,7 @@ proto.improbable.grpcweb.test.PingResponse.prototype.getValue = function() {

/** @param {string} value */
proto.improbable.grpcweb.test.PingResponse.prototype.setValue = function(value) {
jspb.Message.setField(this, 1, value);
jspb.Message.setProto3StringField(this, 1, value);
};


Expand All @@ -530,7 +531,7 @@ proto.improbable.grpcweb.test.PingResponse.prototype.getCounter = function() {

/** @param {number} value */
proto.improbable.grpcweb.test.PingResponse.prototype.setCounter = function(value) {
jspb.Message.setField(this, 2, value);
jspb.Message.setProto3IntField(this, 2, value);
};


Expand Down Expand Up @@ -696,7 +697,7 @@ proto.improbable.grpcweb.test.TextMessage.prototype.getText = function() {

/** @param {string} value */
proto.improbable.grpcweb.test.TextMessage.prototype.setText = function(value) {
jspb.Message.setField(this, 1, value);
jspb.Message.setProto3StringField(this, 1, value);
};


Expand All @@ -713,7 +714,7 @@ proto.improbable.grpcweb.test.TextMessage.prototype.getSendHeaders = function()

/** @param {boolean} value */
proto.improbable.grpcweb.test.TextMessage.prototype.setSendHeaders = function(value) {
jspb.Message.setField(this, 2, value);
jspb.Message.setProto3BooleanField(this, 2, value);
};


Expand All @@ -730,7 +731,7 @@ proto.improbable.grpcweb.test.TextMessage.prototype.getSendTrailers = function()

/** @param {boolean} value */
proto.improbable.grpcweb.test.TextMessage.prototype.setSendTrailers = function(value) {
jspb.Message.setField(this, 3, value);
jspb.Message.setProto3BooleanField(this, 3, value);
};


Expand Down Expand Up @@ -872,7 +873,7 @@ proto.improbable.grpcweb.test.ContinueStreamRequest.prototype.getStreamIdentifie

/** @param {string} value */
proto.improbable.grpcweb.test.ContinueStreamRequest.prototype.setStreamIdentifier = function(value) {
jspb.Message.setField(this, 1, value);
jspb.Message.setProto3StringField(this, 1, value);
};


Expand Down Expand Up @@ -1014,7 +1015,7 @@ proto.improbable.grpcweb.test.CheckStreamClosedRequest.prototype.getStreamIdenti

/** @param {string} value */
proto.improbable.grpcweb.test.CheckStreamClosedRequest.prototype.setStreamIdentifier = function(value) {
jspb.Message.setField(this, 1, value);
jspb.Message.setProto3StringField(this, 1, value);
};


Expand Down Expand Up @@ -1158,7 +1159,7 @@ proto.improbable.grpcweb.test.CheckStreamClosedResponse.prototype.getClosed = fu

/** @param {boolean} value */
proto.improbable.grpcweb.test.CheckStreamClosedResponse.prototype.setClosed = function(value) {
jspb.Message.setField(this, 1, value);
jspb.Message.setProto3BooleanField(this, 1, value);
};


Expand Down
Loading

0 comments on commit 968eb3f

Please sign in to comment.