Class: KubeMQ::Interceptors::ErrorMappingInterceptor Private

Inherits:
GRPC::ClientInterceptor
  • Object
show all
Defined in:
lib/kubemq/interceptors/error_mapping_interceptor.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

gRPC client interceptor that catches GRPC::BadStatus exceptions and converts them to typed Error subclasses via ErrorMapper.

Wraps all four RPC patterns (unary, server-stream, client-stream, bidi-stream) so application code can rescue SDK error types rather than raw gRPC exceptions.

See Also:

Constant Summary collapse

GRPC_MAPPING =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Imported gRPC-to-SDK error mapping table.

ErrorMapper::GRPC_MAPPING

Instance Method Summary collapse

Instance Method Details

#bidi_streamer(requests:, call:, method:, metadata:, &block) ⇒ Enumerator

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns bidirectional response stream.

Parameters:

  • requests (Enumerator)

    the outbound request stream

  • call (GRPC::ActiveCall)

    the active gRPC call

  • method (String)

    the RPC method path

  • metadata (Hash)

    request metadata

Returns:

  • (Enumerator)

    bidirectional response stream

Raises:

  • (Error)

    SDK-typed error mapped from gRPC status



58
59
60
# File 'lib/kubemq/interceptors/error_mapping_interceptor.rb', line 58

def bidi_streamer(requests:, call:, method:, metadata:, &block)
  map_errors(method) { block.call(requests, call, method, ) }
end

#client_streamer(requests:, call:, method:, metadata:, &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the RPC response.

Parameters:

  • requests (Enumerator)

    the outbound request stream

  • call (GRPC::ActiveCall)

    the active gRPC call

  • method (String)

    the RPC method path

  • metadata (Hash)

    request metadata

Returns:

  • (Object)

    the RPC response

Raises:

  • (Error)

    SDK-typed error mapped from gRPC status



48
49
50
# File 'lib/kubemq/interceptors/error_mapping_interceptor.rb', line 48

def client_streamer(requests:, call:, method:, metadata:, &block)
  map_errors(method) { block.call(requests, call, method, ) }
end

#request_response(request:, call:, method:, metadata:, &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the RPC response.

Parameters:

  • request (Object)

    the outbound protobuf message

  • call (GRPC::ActiveCall)

    the active gRPC call

  • method (String)

    the RPC method path

  • metadata (Hash)

    request metadata

Returns:

  • (Object)

    the RPC response

Raises:

  • (Error)

    SDK-typed error mapped from gRPC status



28
29
30
# File 'lib/kubemq/interceptors/error_mapping_interceptor.rb', line 28

def request_response(request:, call:, method:, metadata:, &block)
  map_errors(method) { block.call(request, call, method, ) }
end

#server_streamer(request:, call:, method:, metadata:, &block) ⇒ Enumerator

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns server response stream.

Parameters:

  • request (Object)

    the outbound protobuf message

  • call (GRPC::ActiveCall)

    the active gRPC call

  • method (String)

    the RPC method path

  • metadata (Hash)

    request metadata

Returns:

  • (Enumerator)

    server response stream

Raises:

  • (Error)

    SDK-typed error mapped from gRPC status



38
39
40
# File 'lib/kubemq/interceptors/error_mapping_interceptor.rb', line 38

def server_streamer(request:, call:, method:, metadata:, &block)
  map_errors(method) { block.call(request, call, method, ) }
end