Module: GrpcOpencensusInterceptor::Util
- Defined in:
- lib/grpc_opencensus_interceptor/util.rb
Constant Summary collapse
- OPENCENSUS_TRACE_BIN_KEY =
"grpc-trace-bin".freeze
Class Method Summary collapse
Class Method Details
.to_grpc_ex(e) ⇒ GRPC::BadStatus
Returns e.
46 47 48 49 50 51 52 53 |
# File 'lib/grpc_opencensus_interceptor/util.rb', line 46 def to_grpc_ex(e) case e when GRPC::BadStatus e else GRPC::Unknown.new(e.) end end |
.to_http_status(exception) ⇒ Integer
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/grpc_opencensus_interceptor/util.rb', line 11 def to_http_status(exception) case exception when GRPC::Ok 200 when GRPC::InvalidArgument 400 when GRPC::DeadlineExceeded 504 when GRPC::NotFound 404 when GRPC::PermissionDenied 403 when GRPC::Unauthenticated 401 when GRPC::Aborted # For GRPC::Aborted, grpc-gateway uses 409. We do the same. # cf. https://github.com/grpc-ecosystem/grpc-gateway/blob/e8db07a3923d3f5c77dbcea96656afe43a2757a8/runtime/errors.go#L17-L58 409 when GRPC::ResourceExhausted 429 when GRPC::Unimplemented 501 when GRPC::Unavailable 503 when GRPC::Unknown # NOTE: This is not same with the correct mapping 500 else # NOTE: Here, we use 500 temporarily. 500 end end |