grpc_csds.py
Go to the documentation of this file.
1 # Copyright 2021 The gRPC Authors
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 """
15 This contains helpers for gRPC services defined in
16 https://github.com/envoyproxy/envoy/blob/main/api/envoy/service/status/v3/csds.proto
17 """
18 
19 import logging
20 from typing import Optional
21 
22 # Envoy protos provided by PyPI package xds-protos
23 # Needs to import the generated Python file to load descriptors
24 # pylint: disable=unused-import
25 from envoy.extensions.filters.common.fault.v3 import fault_pb2 as _
26 from envoy.extensions.filters.http.fault.v3 import fault_pb2 as _
27 from envoy.extensions.filters.http.router.v3 import router_pb2 as _
28 from envoy.extensions.filters.network.http_connection_manager.v3 import \
29  http_connection_manager_pb2 as _
30 # pylint: enable=unused-import
31 from envoy.service.status.v3 import csds_pb2
32 from envoy.service.status.v3 import csds_pb2_grpc
33 import grpc
34 
35 import framework.rpc
36 
37 logger = logging.getLogger(__name__)
38 
39 # Type aliases
40 ClientConfig = csds_pb2.ClientConfig
41 _ClientStatusRequest = csds_pb2.ClientStatusRequest
42 
43 
45  stub: csds_pb2_grpc.ClientStatusDiscoveryServiceStub
46 
47  def __init__(self, channel: grpc.Channel):
48  super().__init__(channel,
49  csds_pb2_grpc.ClientStatusDiscoveryServiceStub)
50 
51  def fetch_client_status(self, **kwargs) -> Optional[ClientConfig]:
52  """Fetches the active xDS configurations."""
53  response = self.call_unary_with_deadline(rpc='FetchClientStatus',
55  **kwargs)
56  if len(response.config) != 1:
57  logger.debug('Unexpected number of client configs: %s',
58  len(response.config))
59  return None
60  return response.config[0]
framework.rpc.grpc.GrpcClientHelper
Definition: grpc.py:28
framework.rpc
Definition: tools/run_tests/xds_k8s_test_driver/framework/rpc/__init__.py:1
framework.rpc.grpc.GrpcClientHelper.call_unary_with_deadline
Message call_unary_with_deadline(self, *str rpc, Message req, Optional[int] deadline_sec=DEFAULT_RPC_DEADLINE_SEC, Optional[int] log_level=logging.DEBUG)
Definition: grpc.py:39
framework.rpc.grpc_csds.CsdsClient
Definition: grpc_csds.py:44
framework.rpc.grpc_csds.CsdsClient.__init__
def __init__(self, grpc.Channel channel)
Definition: grpc_csds.py:47
len
int len
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:46
framework.rpc.grpc_csds._ClientStatusRequest
_ClientStatusRequest
Definition: grpc_csds.py:41
framework.rpc.grpc_csds.CsdsClient.fetch_client_status
Optional[ClientConfig] fetch_client_status(self, **kwargs)
Definition: grpc_csds.py:51


grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:59:47