Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add grpc-gateway helper types #102

Merged
merged 1 commit into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ PROTOTOOL_VER=1.8.0
PROTOTOOL_IMAGE=uber/prototool:$(PROTOTOOL_VER)
PROTOTOOL=docker run --rm -u ${shell id -u} -v "${PWD}:/go/src/${PROJECT_ROOT}" -w /go/src/${PROJECT_ROOT} $(PROTOTOOL_IMAGE)

PROTOC_VER=0.4.0
PROTOC_VER=0.5.0
PROTOC_IMAGE=jaegertracing/protobuf:$(PROTOC_VER)
PROTOC=docker run --rm -u ${shell id -u} -v "${PWD}:${PWD}" -w ${PWD} ${PROTOC_IMAGE} --proto_path=${PWD}

Expand Down
27 changes: 27 additions & 0 deletions proto/api_v3/query_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,30 @@ service QueryService {
// GetOperations returns operation names.
rpc GetOperations(GetOperationsRequest) returns (GetOperationsResponse) {}
}

// Below are some helper types when using APIv3 via HTTP endpoints implemented via grpc-gateway.

// GRPCGatewayError is the type returned when GRPC server returns an error.
// Note that for streaming responses it would be wrapped in GRPCGatewayWrapper below.
// Example: {"error":{"grpcCode":2,"httpCode":500,"message":"...","httpStatus":"text..."}}.
message GRPCGatewayError {
message GRPCGatewayErrorDetails {
int32 grpcCode = 1;
int32 httpCode = 2;
string message = 3;
string httpStatus = 4;
}

GRPCGatewayErrorDetails error = 1;
}

// GRPCGatewayWrapper is a type returned when GRPC service returns a stream.
// For some unknown reason grpc-gateway/v1 wraps chunk responses in {"result": {actual output}}.
// See https://github.com/grpc-ecosystem/grpc-gateway/issues/2189
// TODO: it's not clear what happens when the server returns more than one chunk.
// The gateway will presumably combine then into a single HTTP response.
// Currently this is not possible because even though APIv3 GRPC Service is using output stream,
// its implementation reads all spans from QueryService at once and forms only a single chunk.
message GRPCGatewayWrapper {
SpansResponseChunk result = 1;
}
Loading