# Generated by the protocol buffer compiler.  DO NOT EDIT!
# sources: googletypes_service_returns_empty.proto
# plugin: python-betterproto
# This file has been @generated

__all__ = (
    "RequestMessage",
    "TestStub",
    "TestBase",
)


from dataclasses import dataclass
from typing import (
    TYPE_CHECKING,
    Dict,
    Optional,
)

import grpclib

import betterproto_fw
from betterproto_fw.grpc.grpclib_server import ServiceBase


if TYPE_CHECKING:
    import grpclib.server
    from grpclib.metadata import Deadline

    from betterproto_fw.grpc.grpclib_client import MetadataLike


@dataclass(eq=False, repr=False)
class RequestMessage(betterproto_fw.Message):
    """ """

    pass


class TestStub(betterproto_fw.ServiceStub):
    """ """

    async def send(
        self,
        request_message: "RequestMessage",
        *,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None,
    ) -> "betterproto_fw_lib_google_protobuf.Empty":
        """ """

        return await self._unary_unary(
            "/googletypes_service_returns_empty.Test/Send",
            request_message,
            betterproto_fw_lib_google_protobuf.Empty,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )


import betterproto_fw.lib.google.protobuf as betterproto_fw_lib_google_protobuf


class TestBase(ServiceBase):
    """ """

    async def send(
        self, request_message: "RequestMessage"
    ) -> "betterproto_fw_lib_google_protobuf.Empty":
        """ """

        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def __rpc_send(
        self,
        stream: "grpclib.server.Stream[RequestMessage, betterproto_fw_lib_google_protobuf.Empty]",
    ) -> None:
        request = await stream.recv_message()
        response = await self.send(request)
        await stream.send_message(response)

    def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
        return {
            "/googletypes_service_returns_empty.Test/Send": grpclib.const.Handler(
                self.__rpc_send,
                grpclib.const.Cardinality.UNARY_UNARY,
                RequestMessage,
                betterproto_fw_lib_google_protobuf.Empty,
            ),
        }
