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

from typing import TYPE_CHECKING


if TYPE_CHECKING:
    from dataclasses import dataclass
else:
    from pydantic.dataclasses import dataclass

from typing import (
    Dict,
    Optional,
)

import betterproto
import betterproto.lib.pydantic.google.protobuf as betterproto_lib_pydantic_google_protobuf
import grpclib
from betterproto.grpc.grpclib_server import ServiceBase
from pydantic.dataclasses import rebuild_dataclass


@dataclass(eq=False, repr=False)
class RequestMessage(betterproto.Message):
    pass


class TestStub(betterproto.ServiceStub):
    async def send(
        self,
        request_message: "RequestMessage",
        *,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None
    ) -> "betterproto_lib_pydantic_google_protobuf.Empty":
        return await self._unary_unary(
            "/googletypes_service_returns_empty.Test/Send",
            request_message,
            betterproto_lib_pydantic_google_protobuf.Empty,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )


class TestBase(ServiceBase):
    async def send(
        self, request_message: "RequestMessage"
    ) -> "betterproto_lib_pydantic_google_protobuf.Empty":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def __rpc_send(
        self,
        stream: "grpclib.server.Stream[RequestMessage, betterproto_lib_pydantic_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_lib_pydantic_google_protobuf.Empty,
            ),
        }
