# Code generated by sqlc. DO NOT EDIT.
# versions:
#   sqlc v1.29.0
# source: get_executor_statuses.sql
import dataclasses
from typing import AsyncIterator, Iterator, List
import uuid

import sqlalchemy
import sqlalchemy.ext.asyncio

from . import models


GET_EXECUTOR_STATUSES = """-- name: get_executor_statuses \\:many
SELECT
    id,
    status\\:\\:text as status
FROM hyrex_executor
WHERE id = ANY(:p1\\:\\:uuid[])
ORDER BY id
"""


@dataclasses.dataclass()
class GetExecutorStatusesParams:
    executor_ids: List[uuid.UUID]


@dataclasses.dataclass()
class GetExecutorStatusesRow:
    id: uuid.UUID
    status: str


class Querier:
    def __init__(self, conn: sqlalchemy.engine.Connection):
        self._conn = conn

    def get_executor_statuses(self, arg: GetExecutorStatusesParams) -> Iterator[GetExecutorStatusesRow]:
        result = self._conn.execute(sqlalchemy.text(GET_EXECUTOR_STATUSES), {"p1": arg.executor_ids})
        for row in result:
            yield GetExecutorStatusesRow(
                id=row[0],
                status=row[1],
            )


class AsyncQuerier:
    def __init__(self, conn: sqlalchemy.ext.asyncio.AsyncConnection):
        self._conn = conn

    async def get_executor_statuses(self, arg: GetExecutorStatusesParams) -> AsyncIterator[GetExecutorStatusesRow]:
        result = await self._conn.stream(sqlalchemy.text(GET_EXECUTOR_STATUSES), {"p1": arg.executor_ids})
        async for row in result:
            yield GetExecutorStatusesRow(
                id=row[0],
                status=row[1],
            )
