Skip to content

fix grpc: use a new client middleware pipeline #11

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

Merged
merged 8 commits into from
Mar 19, 2025
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
4 changes: 1 addition & 3 deletions configs/static_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ components_manager:
# Optional channel parameters for gRPC Core
# https://grpc.github.io/grpc/core/group__grpc__arg__keys.html
channel-args: {}
middlewares:
- grpc-client-logging
- grpc-client-deadline-propagation

grpc-client-logging:
grpc-client-deadline-propagation:
Expand All @@ -40,6 +37,7 @@ components_manager:
service-defaults:
task-processor: main-task-processor

grpc-client-middlewares-pipeline:
grpc-server-middlewares-pipeline:

congestion-control:
Expand Down
8 changes: 2 additions & 6 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
#include <userver/storages/mongo/component.hpp>
#include <userver/testsuite/testsuite_support.hpp>
#include <userver/ugrpc/client/client_factory_component.hpp>
#include <userver/ugrpc/client/common_component.hpp>
#include <userver/ugrpc/client/middlewares/deadline_propagation/component.hpp>
#include <userver/ugrpc/client/middlewares/log/component.hpp>
#include <userver/ugrpc/client/component_list.hpp>
#include <userver/ugrpc/server/component_list.hpp>
#include <userver/utils/daemon_run.hpp>

Expand All @@ -20,11 +18,9 @@ int main(int argc, char* argv[]) {
auto component_list =
userver::components::MinimalServerComponentList()
.AppendComponentList(userver::ugrpc::server::MinimalComponentList())
.AppendComponentList(userver::ugrpc::client::MinimalComponentList())
.Append<userver::congestion_control::Component>()
.Append<userver::ugrpc::client::CommonComponent>()
.Append<userver::ugrpc::client::ClientFactoryComponent>()
.Append<userver::ugrpc::client::middlewares::deadline_propagation::Component>()
.Append<userver::ugrpc::client::middlewares::log::Component>()
.Append<userver::server::handlers::Ping>()
.Append<userver::components::TestsuiteSupport>()
.Append<userver::components::HttpClient>()
Expand Down
15 changes: 0 additions & 15 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,6 @@ def grpc_service(grpc_channel, service_client):
return hello_services.HelloServiceStub(grpc_channel)


@pytest.fixture(scope='session')
def mock_grpc_hello_session(grpc_mockserver, create_grpc_mock):
mock = create_grpc_mock(hello_services.HelloServiceServicer)
hello_services.add_HelloServiceServicer_to_server(
mock.servicer, grpc_mockserver,
)
return mock


@pytest.fixture
def mock_grpc_server(mock_grpc_hello_session):
with mock_grpc_hello_session.mock() as mock:
yield mock


@pytest.fixture(scope='session')
def prepare_service_config(grpc_mockserver_endpoint):
def patch_config(config, config_vars):
Expand Down
7 changes: 4 additions & 3 deletions tests/test_hello.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import pytest

import handlers.hello_pb2 as hello_protos # noqa: E402, E501
import handlers.hello_pb2 as hello_protos
import handlers.hello_pb2_grpc as hello_grpc

# Start the tests via `make test-debug` or `make test-release`


async def test_grpc_client(mock_grpc_server, grpc_service):
@mock_grpc_server('SayHello')
async def test_grpc_client(grpc_mockserver_new, grpc_service):
@grpc_mockserver_new(hello_grpc.HelloServiceServicer.SayHello)
async def mock_say_hello(request, context):
assert request.name
return hello_protos.HelloResponse(
Expand Down