# Generated by the protocol buffer compiler.  DO NOT EDIT!
# sources: app/log/command/config.proto
# plugin: python-betterproto2
# This file has been @generated

__all__ = (
    "Config",
    "RestartLoggerRequest",
    "RestartLoggerResponse",
    "LoggerServiceStub",
    "LoggerServiceBase",
)

from dataclasses import dataclass
from typing import TYPE_CHECKING

import betterproto2
import grpclib
from betterproto2.grpc.grpclib_server import ServiceBase

from .....message_pool import default_message_pool

if TYPE_CHECKING:
    import grpclib.server
    from betterproto2.grpc.grpclib_client import MetadataLike
    from grpclib.metadata import Deadline

betterproto2.check_compiler_version("0.5.1")


@dataclass(eq=False, repr=False)
class Config(betterproto2.Message):
    pass


default_message_pool.register_message("xray.app.log.command", "Config", Config)


@dataclass(eq=False, repr=False)
class RestartLoggerRequest(betterproto2.Message):
    pass


default_message_pool.register_message(
    "xray.app.log.command", "RestartLoggerRequest", RestartLoggerRequest
)


@dataclass(eq=False, repr=False)
class RestartLoggerResponse(betterproto2.Message):
    pass


default_message_pool.register_message(
    "xray.app.log.command", "RestartLoggerResponse", RestartLoggerResponse
)


class LoggerServiceStub(betterproto2.ServiceStub):
    async def restart_logger(
        self,
        message: "RestartLoggerRequest | None" = None,
        *,
        timeout: "float | None" = None,
        deadline: "Deadline | None" = None,
        metadata: "MetadataLike | None" = None,
    ) -> "RestartLoggerResponse":
        if message is None:
            message = RestartLoggerRequest()

        return await self._unary_unary(
            "/xray.app.log.command.LoggerService/RestartLogger",
            message,
            RestartLoggerResponse,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )


class LoggerServiceBase(ServiceBase):
    async def restart_logger(
        self, message: "RestartLoggerRequest"
    ) -> "RestartLoggerResponse":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def __rpc_restart_logger(
        self,
        stream: "grpclib.server.Stream[RestartLoggerRequest, RestartLoggerResponse]",
    ) -> None:
        request = await stream.recv_message()
        response = await self.restart_logger(request)
        await stream.send_message(response)

    def __mapping__(self) -> "dict[str, grpclib.const.Handler]":
        return {
            "/xray.app.log.command.LoggerService/RestartLogger": grpclib.const.Handler(
                self.__rpc_restart_logger,
                grpclib.const.Cardinality.UNARY_UNARY,
                RestartLoggerRequest,
                RestartLoggerResponse,
            ),
        }
