Class: GrpcMock::GrpcStubAdapter::AdapterClass
- Inherits:
-
GRPC::ClientStub
- Object
- GRPC::ClientStub
- GrpcMock::GrpcStubAdapter::AdapterClass
- Defined in:
- lib/grpc_mock/grpc_stub_adapter.rb
Overview
To make hook point for GRPC::ClientStub github.com/grpc/grpc/blob/bec3b5ada2c5e5d782dff0b7b5018df646b65cb0/src/ruby/lib/grpc/generic/service.rb#L150-L186
Instance Method Summary collapse
- #bidi_streamer(method, requests, *args, metadata: {}, **kwargs) ⇒ Object
-
#client_streamer(method, requests, *args, metadata: {}, **kwargs) ⇒ Object
TODO.
- #request_response(method, request, *args, metadata: {}, **kwargs) ⇒ Object
- #server_streamer(method, request, *args, metadata: {}, **kwargs) ⇒ Object
Instance Method Details
#bidi_streamer(method, requests, *args, metadata: {}, **kwargs) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/grpc_mock/grpc_stub_adapter.rb', line 62 def bidi_streamer(method, requests, *args, metadata: {}, **kwargs) unless GrpcMock::GrpcStubAdapter.enabled? return super end r = requests.to_a # FIXME: this may not work mock = GrpcMock.stub_registry.response_for_request(method, r) if mock mock.evaluate(r, nil) # FIXME: provide BidiCall equivalent elsif GrpcMock.config.allow_net_connect super else raise NetConnectNotAllowedError, method end end |
#client_streamer(method, requests, *args, metadata: {}, **kwargs) ⇒ Object
TODO
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/grpc_mock/grpc_stub_adapter.rb', line 29 def client_streamer(method, requests, *args, metadata: {}, **kwargs) unless GrpcMock::GrpcStubAdapter.enabled? return super end r = requests.to_a # FIXME: this may not work mock = GrpcMock.stub_registry.response_for_request(method, r) if mock call = GrpcMock::MockedCall.new(metadata: ) mock.evaluate(r, call.multi_req_view) elsif GrpcMock.config.allow_net_connect super else raise NetConnectNotAllowedError, method end end |
#request_response(method, request, *args, metadata: {}, **kwargs) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/grpc_mock/grpc_stub_adapter.rb', line 12 def request_response(method, request, *args, metadata: {}, **kwargs) unless GrpcMock::GrpcStubAdapter.enabled? return super end mock = GrpcMock.stub_registry.response_for_request(method, request) if mock call = GrpcMock::MockedCall.new(metadata: ) mock.evaluate(request, call.single_req_view) elsif GrpcMock.config.allow_net_connect super else raise NetConnectNotAllowedError, method end end |
#server_streamer(method, request, *args, metadata: {}, **kwargs) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/grpc_mock/grpc_stub_adapter.rb', line 46 def server_streamer(method, request, *args, metadata: {}, **kwargs) unless GrpcMock::GrpcStubAdapter.enabled? return super end mock = GrpcMock.stub_registry.response_for_request(method, request) if mock call = GrpcMock::MockedCall.new(metadata: ) mock.evaluate(request, call.single_req_view) elsif GrpcMock.config.allow_net_connect super else raise NetConnectNotAllowedError, method end end |