Skip to content

Commit

Permalink
Add an endopint that always errors
Browse files Browse the repository at this point in the history
  • Loading branch information
rogchap committed Apr 16, 2019
1 parent 7a584ae commit 7782921
Show file tree
Hide file tree
Showing 9 changed files with 192 additions and 175 deletions.
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,18 @@ example-build-frontend:
example-build-backend:
protoc -I./example --go_out=plugins=grpc:example/server example/*.proto

example-build: example-build-backend example-build-frontend

example-frontend-up: example-build-frontend
npm run start --prefix example/client

example-envoy:
docker build -t grpcweb-devtools-example/envoy -f ./example/envoy.Dockerfile ./example

example-server: example-build-backend
example-server:
docker build -t grpcweb-devtools-example/server ./example/server

example-client: example-build-frontend
example-client:
docker build -t grpcweb-devtools-example/client ./example/client

example-up: example-server example-envoy example-server example-client
Expand Down
11 changes: 10 additions & 1 deletion example/client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ function exampleTwo() {
}).catch(console.error)
}

function alwaysError() {
const req = new ExampleOneRequest();
client.alwaysError(req).then(res => {
document.body.innerHTML += `<div>${res.getMsg()}</div>`
}).catch(console.error)
}


exampleOne()
setInterval(exampleOne, 8000)
setInterval(exampleTwo, 10000)
setInterval(exampleTwo, 10000)
setInterval(alwaysError, 15000)
55 changes: 55 additions & 0 deletions example/client/example_grpc_web_pb.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,5 +199,60 @@ proto.s12.example.ExampleServicePromiseClient.prototype.exampleTwo =
};


/**
* @const
* @type {!grpc.web.AbstractClientBase.MethodInfo<
* !proto.s12.example.ExampleOneRequest,
* !proto.s12.example.ExampleOneResponse>}
*/
const methodInfo_ExampleService_AlwaysError = new grpc.web.AbstractClientBase.MethodInfo(
proto.s12.example.ExampleOneResponse,
/** @param {!proto.s12.example.ExampleOneRequest} request */
function(request) {
return request.serializeBinary();
},
proto.s12.example.ExampleOneResponse.deserializeBinary
);


/**
* @param {!proto.s12.example.ExampleOneRequest} request The
* request proto
* @param {?Object<string, string>} metadata User defined
* call metadata
* @param {function(?grpc.web.Error, ?proto.s12.example.ExampleOneResponse)}
* callback The callback function(error, response)
* @return {!grpc.web.ClientReadableStream<!proto.s12.example.ExampleOneResponse>|undefined}
* The XHR Node Readable Stream
*/
proto.s12.example.ExampleServiceClient.prototype.alwaysError =
function(request, metadata, callback) {
return this.client_.rpcCall(this.hostname_ +
'/s12.example.ExampleService/AlwaysError',
request,
metadata || {},
methodInfo_ExampleService_AlwaysError,
callback);
};


/**
* @param {!proto.s12.example.ExampleOneRequest} request The
* request proto
* @param {?Object<string, string>} metadata User defined
* call metadata
* @return {!Promise<!proto.s12.example.ExampleOneResponse>}
* A native promise that resolves to the response
*/
proto.s12.example.ExampleServicePromiseClient.prototype.alwaysError =
function(request, metadata) {
return this.client_.unaryCall(this.hostname_ +
'/s12.example.ExampleService/AlwaysError',
request,
metadata || {},
methodInfo_ExampleService_AlwaysError);
};


module.exports = proto.s12.example;

1 change: 1 addition & 0 deletions example/example.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ option go_package = "main";
service ExampleService {
rpc ExampleOne(ExampleOneRequest) returns (ExampleOneResponse);
rpc ExampleTwo(ExampleTwoRequest) returns (ExampleTwoResponse);
rpc AlwaysError(ExampleOneRequest) returns (ExampleOneResponse);
}

message ExampleOneRequest {
Expand Down
190 changes: 90 additions & 100 deletions example/server/example.pb.go

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

Loading

0 comments on commit 7782921

Please sign in to comment.