# Generated by the protocol buffer compiler.  DO NOT EDIT!
# sources: monitoring.proto
# plugin: python-betterproto
from dataclasses import dataclass
from typing import TYPE_CHECKING, AsyncIterator, Dict, Optional

import betterproto
import grpclib
from betterproto.grpc.grpclib_server import ServiceBase

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


@dataclass(eq=False, repr=False)
class StatsReq(betterproto.Message):
    use_metadata: bool = betterproto.bool_field(1)
    refresh_time_period_in_ms: int = betterproto.uint64_field(4)


@dataclass(eq=False, repr=False)
class StatsResp(betterproto.Message):
    stats: Dict[str, str] = betterproto.map_field(
        1, betterproto.TYPE_STRING, betterproto.TYPE_STRING
    )


class MonitoringStub(betterproto.ServiceStub):
    async def stats(
        self,
        stats_req: "StatsReq",
        *,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None,
    ) -> AsyncIterator["StatsResp"]:
        async for response in self._unary_stream(
            "/event_store.client.monitoring.Monitoring/Stats",
            stats_req,
            StatsResp,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        ):
            yield response


class MonitoringBase(ServiceBase):
    async def stats(self, stats_req: "StatsReq") -> AsyncIterator["StatsResp"]:
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def __rpc_stats(
        self, stream: "grpclib.server.Stream[StatsReq, StatsResp]"
    ) -> None:
        request = await stream.recv_message()
        await self._call_rpc_handler_server_stream(
            self.stats,
            stream,
            request,
        )

    def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
        return {
            "/event_store.client.monitoring.Monitoring/Stats": grpclib.const.Handler(
                self.__rpc_stats,
                grpclib.const.Cardinality.UNARY_STREAM,
                StatsReq,
                StatsResp,
            ),
        }
