Skip to content

Commit

Permalink
runtime: replace StreamError with status.Status
Browse files Browse the repository at this point in the history
Following on from #1242, this replace the StreamError
with a status.Status type. Also, remove the ability to configure
the stream error handler. The existing handler was specific to the
old type, and we can add something better back in later
if necessary.

Fixes #1098
  • Loading branch information
johanbrandhorst committed May 2, 2020
1 parent bacf8a9 commit 53da419
Show file tree
Hide file tree
Showing 18 changed files with 28 additions and 433 deletions.
14 changes: 3 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ SWAGGER_PLUGIN_FLAGS?=
GOOGLEAPIS_DIR=third_party/googleapis
OUTPUT_DIR=_output

RUNTIME_PROTO=internal/errors.proto
RUNTIME_GO=$(RUNTIME_PROTO:.proto=.pb.go)

OPENAPIV2_PROTO=protoc-gen-swagger/options/openapiv2.proto protoc-gen-swagger/options/annotations.proto
OPENAPIV2_GO=$(OPENAPIV2_PROTO:.proto=.pb.go)

Expand Down Expand Up @@ -143,20 +140,15 @@ SWAGGER_CODEGEN=swagger-codegen

PROTOC_INC_PATH=$(dir $(shell which protoc))/../include

generate: $(RUNTIME_GO)

.SUFFIXES: .go .proto

$(GO_PLUGIN):
go build -o $(GO_PLUGIN) $(GO_PLUGIN_PKG)

$(RUNTIME_GO): $(RUNTIME_PROTO) $(GO_PLUGIN)
protoc -I $(PROTOC_INC_PATH) --plugin=$(GO_PLUGIN) -I. --go_out=$(PKGMAP),paths=source_relative:. $(RUNTIME_PROTO)

$(OPENAPIV2_GO): $(OPENAPIV2_PROTO) $(GO_PLUGIN)
protoc -I $(PROTOC_INC_PATH) --plugin=$(GO_PLUGIN) -I. --go_out=$(PKGMAP),paths=source_relative:. $(OPENAPIV2_PROTO)

$(GATEWAY_PLUGIN): $(RUNTIME_GO) $(GATEWAY_PLUGIN_SRC)
$(GATEWAY_PLUGIN): $(GATEWAY_PLUGIN_SRC)
go build -o $@ $(GATEWAY_PLUGIN_PKG)

$(SWAGGER_PLUGIN): $(SWAGGER_PLUGIN_SRC) $(OPENAPIV2_GO)
Expand Down Expand Up @@ -234,11 +226,11 @@ changelog:
--future-release=v1.14.4
lint:
golint --set_exit_status ./runtime
golint --set_exit_status ././internal/utilities/...
golint --set_exit_status ./internal/utilities/...
golint --set_exit_status ./protoc-gen-grpc-gateway/...
golint --set_exit_status ./protoc-gen-swagger/...
go vet ./runtime || true
go vet ././internal/utilities/...
go vet ./internal/utilities/...
go vet ./protoc-gen-grpc-gateway/...
go vet ./protoc-gen-swagger/...

Expand Down
29 changes: 4 additions & 25 deletions examples/internal/clients/responsebody/api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ paths:
result:
$ref: "#/definitions/examplepbResponseBodyOutResponse"
error:
$ref: "#/definitions/runtimeStreamError"
$ref: "#/definitions/rpcStatus"
title: "Stream result of examplepbResponseBodyOut"
default:
description: "An unexpected error response"
Expand Down Expand Up @@ -216,49 +216,28 @@ definitions:
type: "array"
items:
$ref: "#/definitions/protobufAny"
runtimeStreamError:
type: "object"
properties:
grpc_code:
type: "integer"
format: "int32"
http_code:
type: "integer"
format: "int32"
message:
type: "string"
http_status:
type: "string"
details:
type: "array"
items:
$ref: "#/definitions/protobufAny"
example:
http_code: 6
http_status: "http_status"
code: 0
details:
- value: "value"
type_url: "type_url"
- value: "value"
type_url: "type_url"
message: "message"
grpc_code: 0
Stream result of examplepbResponseBodyOut:
properties:
result:
$ref: "#/definitions/examplepbResponseBodyOutResponse"
error:
$ref: "#/definitions/runtimeStreamError"
$ref: "#/definitions/rpcStatus"
example:
result:
data: "data"
error:
http_code: 6
http_status: "http_status"
code: 0
details:
- value: "value"
type_url: "type_url"
- value: "value"
type_url: "type_url"
message: "message"
grpc_code: 0
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Result** | [***ExamplepbResponseBodyOutResponse**](examplepbResponseBodyOutResponse.md) | | [optional] [default to null]
**Error_** | [***RuntimeStreamError**](runtimeStreamError.md) | | [optional] [default to null]
**Error_** | [***RpcStatus**](rpcStatus.md) | | [optional] [default to null]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ package responsebody

type StreamResultOfExamplepbResponseBodyOut struct {
Result *ExamplepbResponseBodyOutResponse `json:"result,omitempty"`
Error_ *RuntimeStreamError `json:"error,omitempty"`
Error_ *RpcStatus `json:"error,omitempty"`
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"$ref": "#/definitions/examplepbResponseBodyOutResponse"
},
"error": {
"$ref": "#/definitions/runtimeStreamError"
"$ref": "#/definitions/rpcStatus"
}
},
"title": "Stream result of examplepbResponseBodyOut"
Expand Down Expand Up @@ -239,31 +239,6 @@
}
}
}
},
"runtimeStreamError": {
"type": "object",
"properties": {
"grpc_code": {
"type": "integer",
"format": "int32"
},
"http_code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
},
"http_status": {
"type": "string"
},
"details": {
"type": "array",
"items": {
"$ref": "#/definitions/protobufAny"
}
}
}
}
}
}
29 changes: 2 additions & 27 deletions examples/internal/proto/examplepb/stream.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"$ref": "#/definitions/examplepbABitOfEverything"
},
"error": {
"$ref": "#/definitions/runtimeStreamError"
"$ref": "#/definitions/rpcStatus"
}
},
"title": "Stream result of examplepbABitOfEverything"
Expand Down Expand Up @@ -88,7 +88,7 @@
"$ref": "#/definitions/subStringMessage"
},
"error": {
"$ref": "#/definitions/runtimeStreamError"
"$ref": "#/definitions/rpcStatus"
}
},
"title": "Stream result of subStringMessage"
Expand Down Expand Up @@ -395,31 +395,6 @@
}
}
},
"runtimeStreamError": {
"type": "object",
"properties": {
"grpc_code": {
"type": "integer",
"format": "int32"
},
"http_code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
},
"http_status": {
"type": "string"
},
"details": {
"type": "array",
"items": {
"$ref": "#/definitions/protobufAny"
}
}
}
},
"subStringMessage": {
"type": "object",
"properties": {
Expand Down
23 changes: 0 additions & 23 deletions internal/BUILD.bazel

This file was deleted.

Loading

0 comments on commit 53da419

Please sign in to comment.