use std::sync::Arc;
use tokio::sync::Mutex;
use tokio_util::sync::CancellationToken;
use crate::autoscaler::AutoscalerConfig;
use crate::backend::{Backend, RegistryImpl};
#[diagnostic::on_unimplemented(
message = "`{Self}` has no coordinated consumer-group primitive; use `broker.consumer_supervisor()` instead.",
note = "Kafka, RabbitMQ, NATS, InMemory, and Redis (redis-streams) implement `HasCoordinatedGroups`. SQS runs N parallel independent consumers via the supervisor."
)]
#[allow(private_interfaces, private_bounds)]
pub trait HasCoordinatedGroups: Backend {
type ConsumerGroupConfig: Default + Clone + Send + 'static;
type RegistryImpl: RegistryImpl<GroupConfig = Self::ConsumerGroupConfig> + Send + 'static;
fn make_registry(client: &Self::Client) -> Self::RegistryImpl;
fn spawn_autoscaler(
client: &Self::Client,
registry: Arc<Mutex<Self::RegistryImpl>>,
config: AutoscalerConfig,
shutdown: CancellationToken,
) -> tokio::task::JoinHandle<()>;
}