1# Copyright 2020 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"""AsyncIO version of Channelz servicer.""" 15 16from grpc.experimental import aio 17from grpc_channelz.v1._servicer import ChannelzServicer as _SyncChannelzServicer 18import grpc_channelz.v1.channelz_pb2 as _channelz_pb2 19import grpc_channelz.v1.channelz_pb2_grpc as _channelz_pb2_grpc 20 21 22class ChannelzServicer(_channelz_pb2_grpc.ChannelzServicer): 23 """AsyncIO servicer for handling RPCs for service statuses.""" 24 25 @staticmethod 26 async def GetTopChannels( 27 request: _channelz_pb2.GetTopChannelsRequest, 28 context: aio.ServicerContext, 29 ) -> _channelz_pb2.GetTopChannelsResponse: 30 return _SyncChannelzServicer.GetTopChannels(request, context) 31 32 @staticmethod 33 async def GetServers( 34 request: _channelz_pb2.GetServersRequest, context: aio.ServicerContext 35 ) -> _channelz_pb2.GetServersResponse: 36 return _SyncChannelzServicer.GetServers(request, context) 37 38 @staticmethod 39 async def GetServer( 40 request: _channelz_pb2.GetServerRequest, context: aio.ServicerContext 41 ) -> _channelz_pb2.GetServerResponse: 42 return _SyncChannelzServicer.GetServer(request, context) 43 44 @staticmethod 45 async def GetServerSockets( 46 request: _channelz_pb2.GetServerSocketsRequest, 47 context: aio.ServicerContext, 48 ) -> _channelz_pb2.GetServerSocketsResponse: 49 return _SyncChannelzServicer.GetServerSockets(request, context) 50 51 @staticmethod 52 async def GetChannel( 53 request: _channelz_pb2.GetChannelRequest, context: aio.ServicerContext 54 ) -> _channelz_pb2.GetChannelResponse: 55 return _SyncChannelzServicer.GetChannel(request, context) 56 57 @staticmethod 58 async def GetSubchannel( 59 request: _channelz_pb2.GetSubchannelRequest, 60 context: aio.ServicerContext, 61 ) -> _channelz_pb2.GetSubchannelResponse: 62 return _SyncChannelzServicer.GetSubchannel(request, context) 63 64 @staticmethod 65 async def GetSocket( 66 request: _channelz_pb2.GetSocketRequest, context: aio.ServicerContext 67 ) -> _channelz_pb2.GetSocketResponse: 68 return _SyncChannelzServicer.GetSocket(request, context) 69