"""
@generated by mypy-protobuf.  Do not edit manually!
isort:skip_file
Copyright 2025 Redpanda Data, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import abc
import collections.abc
import grpc
import grpc.aio
from .... import redpanda
import typing
_T = typing.TypeVar('_T')

class _MaybeAsyncIterator(collections.abc.AsyncIterator[_T], collections.abc.Iterator[_T], metaclass=abc.ABCMeta):
    ...

class _ServicerContext(grpc.ServicerContext, grpc.aio.ServicerContext):
    ...

class BatchInputServiceStub:
    """BatchInput is an interface implemented by Benthos inputs that produce
    messages in batches, where there is a desire to process and send the batch as
    a logical group rather than as individual messages.

    Calls to ReadBatch should block until either a message batch is ready to
    process, the connection is lost, or the RPC deadline is reached.
    """

    def __init__(self, channel: typing.Union[grpc.Channel, grpc.aio.Channel]) -> None:
        ...
    Init: grpc.UnaryUnaryMultiCallable[redpanda.runtime.v1alpha1.input_pb2.BatchInputInitRequest, redpanda.runtime.v1alpha1.input_pb2.BatchInputInitResponse]
    "Init is the first method called for a batch input and it passes the user's\n    configuration to the input.\n\n    The schema for the input configuration is specified in the `plugin.yaml`\n    file provided to Redpanda Connect.\n    "
    Connect: grpc.UnaryUnaryMultiCallable[redpanda.runtime.v1alpha1.input_pb2.BatchInputConnectRequest, redpanda.runtime.v1alpha1.input_pb2.BatchInputConnectResponse]
    'Establish a connection to the upstream service. Connect will always be\n    called first when a reader is instantiated, and will be continuously\n    called with back off until a nil error is returned.\n\n    Once Connect returns a nil error the Read method will be called until\n    either ErrNotConnected is returned, or the reader is closed.\n    '
    ReadBatch: grpc.UnaryUnaryMultiCallable[redpanda.runtime.v1alpha1.input_pb2.BatchInputReadRequest, redpanda.runtime.v1alpha1.input_pb2.BatchInputReadResponse]
    "Read a message batch from a source, along with a function to be called\n    once the entire batch can be either acked (successfully sent or\n    intentionally filtered) or nacked (failed to be processed or dispatched\n    to the output).\n\n    The Ack will be called for every message batch at least once, but\n    there are no guarantees as to when this will occur. If your input\n    implementation doesn't have a specific mechanism for dealing with a nack\n    then you can instruct the Connect framework to auto_replay_nacks in the\n    InitResponse to get automatic retries.\n\n    If this method returns Error.NotConnected then ReadBatch will not be called\n    again until Connect has returned a nil error. If Error.EndOfInput is\n    returned then Read will no longer be called and the pipeline will\n    gracefully terminate.\n    "
    Ack: grpc.UnaryUnaryMultiCallable[redpanda.runtime.v1alpha1.input_pb2.BatchInputAckRequest, redpanda.runtime.v1alpha1.input_pb2.BatchInputAckResponse]
    "Acknowledge a message batch. This function ensures that the source of the\n    message receives either an acknowledgement (error is missing) or an error\n    that can either be propagated upstream as a nack, or trigger a reattempt at\n    delivering the same message.\n\n    If your input implementation doesn't have a specific mechanism for dealing\n    with a nack then you can wrap your input implementation with AutoRetryNacks\n    to get automatic retries, and noop this function.\n    "
    Close: grpc.UnaryUnaryMultiCallable[redpanda.runtime.v1alpha1.input_pb2.BatchInputCloseRequest, redpanda.runtime.v1alpha1.input_pb2.BatchInputCloseResponse]
    'Close the component, blocks until either the underlying resources are\n    cleaned up or the RPC deadline is reached.\n    '

class BatchInputServiceAsyncStub:
    """BatchInput is an interface implemented by Benthos inputs that produce
    messages in batches, where there is a desire to process and send the batch as
    a logical group rather than as individual messages.

    Calls to ReadBatch should block until either a message batch is ready to
    process, the connection is lost, or the RPC deadline is reached.
    """
    Init: grpc.aio.UnaryUnaryMultiCallable[redpanda.runtime.v1alpha1.input_pb2.BatchInputInitRequest, redpanda.runtime.v1alpha1.input_pb2.BatchInputInitResponse]
    "Init is the first method called for a batch input and it passes the user's\n    configuration to the input.\n\n    The schema for the input configuration is specified in the `plugin.yaml`\n    file provided to Redpanda Connect.\n    "
    Connect: grpc.aio.UnaryUnaryMultiCallable[redpanda.runtime.v1alpha1.input_pb2.BatchInputConnectRequest, redpanda.runtime.v1alpha1.input_pb2.BatchInputConnectResponse]
    'Establish a connection to the upstream service. Connect will always be\n    called first when a reader is instantiated, and will be continuously\n    called with back off until a nil error is returned.\n\n    Once Connect returns a nil error the Read method will be called until\n    either ErrNotConnected is returned, or the reader is closed.\n    '
    ReadBatch: grpc.aio.UnaryUnaryMultiCallable[redpanda.runtime.v1alpha1.input_pb2.BatchInputReadRequest, redpanda.runtime.v1alpha1.input_pb2.BatchInputReadResponse]
    "Read a message batch from a source, along with a function to be called\n    once the entire batch can be either acked (successfully sent or\n    intentionally filtered) or nacked (failed to be processed or dispatched\n    to the output).\n\n    The Ack will be called for every message batch at least once, but\n    there are no guarantees as to when this will occur. If your input\n    implementation doesn't have a specific mechanism for dealing with a nack\n    then you can instruct the Connect framework to auto_replay_nacks in the\n    InitResponse to get automatic retries.\n\n    If this method returns Error.NotConnected then ReadBatch will not be called\n    again until Connect has returned a nil error. If Error.EndOfInput is\n    returned then Read will no longer be called and the pipeline will\n    gracefully terminate.\n    "
    Ack: grpc.aio.UnaryUnaryMultiCallable[redpanda.runtime.v1alpha1.input_pb2.BatchInputAckRequest, redpanda.runtime.v1alpha1.input_pb2.BatchInputAckResponse]
    "Acknowledge a message batch. This function ensures that the source of the\n    message receives either an acknowledgement (error is missing) or an error\n    that can either be propagated upstream as a nack, or trigger a reattempt at\n    delivering the same message.\n\n    If your input implementation doesn't have a specific mechanism for dealing\n    with a nack then you can wrap your input implementation with AutoRetryNacks\n    to get automatic retries, and noop this function.\n    "
    Close: grpc.aio.UnaryUnaryMultiCallable[redpanda.runtime.v1alpha1.input_pb2.BatchInputCloseRequest, redpanda.runtime.v1alpha1.input_pb2.BatchInputCloseResponse]
    'Close the component, blocks until either the underlying resources are\n    cleaned up or the RPC deadline is reached.\n    '

class BatchInputServiceServicer(metaclass=abc.ABCMeta):
    """BatchInput is an interface implemented by Benthos inputs that produce
    messages in batches, where there is a desire to process and send the batch as
    a logical group rather than as individual messages.

    Calls to ReadBatch should block until either a message batch is ready to
    process, the connection is lost, or the RPC deadline is reached.
    """

    @abc.abstractmethod
    def Init(self, request: redpanda.runtime.v1alpha1.input_pb2.BatchInputInitRequest, context: _ServicerContext) -> typing.Union[redpanda.runtime.v1alpha1.input_pb2.BatchInputInitResponse, collections.abc.Awaitable[redpanda.runtime.v1alpha1.input_pb2.BatchInputInitResponse]]:
        """Init is the first method called for a batch input and it passes the user's
        configuration to the input.

        The schema for the input configuration is specified in the `plugin.yaml`
        file provided to Redpanda Connect.
        """

    @abc.abstractmethod
    def Connect(self, request: redpanda.runtime.v1alpha1.input_pb2.BatchInputConnectRequest, context: _ServicerContext) -> typing.Union[redpanda.runtime.v1alpha1.input_pb2.BatchInputConnectResponse, collections.abc.Awaitable[redpanda.runtime.v1alpha1.input_pb2.BatchInputConnectResponse]]:
        """Establish a connection to the upstream service. Connect will always be
        called first when a reader is instantiated, and will be continuously
        called with back off until a nil error is returned.

        Once Connect returns a nil error the Read method will be called until
        either ErrNotConnected is returned, or the reader is closed.
        """

    @abc.abstractmethod
    def ReadBatch(self, request: redpanda.runtime.v1alpha1.input_pb2.BatchInputReadRequest, context: _ServicerContext) -> typing.Union[redpanda.runtime.v1alpha1.input_pb2.BatchInputReadResponse, collections.abc.Awaitable[redpanda.runtime.v1alpha1.input_pb2.BatchInputReadResponse]]:
        """Read a message batch from a source, along with a function to be called
        once the entire batch can be either acked (successfully sent or
        intentionally filtered) or nacked (failed to be processed or dispatched
        to the output).

        The Ack will be called for every message batch at least once, but
        there are no guarantees as to when this will occur. If your input
        implementation doesn't have a specific mechanism for dealing with a nack
        then you can instruct the Connect framework to auto_replay_nacks in the
        InitResponse to get automatic retries.

        If this method returns Error.NotConnected then ReadBatch will not be called
        again until Connect has returned a nil error. If Error.EndOfInput is
        returned then Read will no longer be called and the pipeline will
        gracefully terminate.
        """

    @abc.abstractmethod
    def Ack(self, request: redpanda.runtime.v1alpha1.input_pb2.BatchInputAckRequest, context: _ServicerContext) -> typing.Union[redpanda.runtime.v1alpha1.input_pb2.BatchInputAckResponse, collections.abc.Awaitable[redpanda.runtime.v1alpha1.input_pb2.BatchInputAckResponse]]:
        """Acknowledge a message batch. This function ensures that the source of the
        message receives either an acknowledgement (error is missing) or an error
        that can either be propagated upstream as a nack, or trigger a reattempt at
        delivering the same message.

        If your input implementation doesn't have a specific mechanism for dealing
        with a nack then you can wrap your input implementation with AutoRetryNacks
        to get automatic retries, and noop this function.
        """

    @abc.abstractmethod
    def Close(self, request: redpanda.runtime.v1alpha1.input_pb2.BatchInputCloseRequest, context: _ServicerContext) -> typing.Union[redpanda.runtime.v1alpha1.input_pb2.BatchInputCloseResponse, collections.abc.Awaitable[redpanda.runtime.v1alpha1.input_pb2.BatchInputCloseResponse]]:
        """Close the component, blocks until either the underlying resources are
        cleaned up or the RPC deadline is reached.
        """

def add_BatchInputServiceServicer_to_server(servicer: BatchInputServiceServicer, server: typing.Union[grpc.Server, grpc.aio.Server]) -> None:
    ...