use crate::client::handle::ClientBuilder;
use proxima_config::sugar::SpecBuilder;
pub trait ClientProtocolExt: Sized {
#[must_use]
fn http(self, url: impl Into<String>) -> Self;
#[must_use]
fn https(self, url: impl Into<String>) -> Self;
#[must_use]
fn grpc(self, url: impl Into<String>) -> Self;
#[cfg(all(
feature = "kafka-client",
any(target_os = "linux", target_os = "macos", target_os = "windows")
))]
#[must_use]
fn kafka(self, dsn: impl Into<String>) -> Self;
#[cfg(all(
feature = "mqtt-client",
any(target_os = "linux", target_os = "macos", target_os = "windows")
))]
#[must_use]
fn mqtt(self, dsn: impl Into<String>) -> Self;
#[cfg(all(
feature = "amqp-client",
any(target_os = "linux", target_os = "macos", target_os = "windows")
))]
#[must_use]
fn amqp(self, dsn: impl Into<String>) -> Self;
#[cfg(all(
feature = "dns-client",
any(target_os = "linux", target_os = "macos", target_os = "windows")
))]
#[must_use]
fn dns(self, dsn: impl Into<String>) -> Self;
#[cfg(all(
feature = "memcached-client",
any(target_os = "linux", target_os = "macos", target_os = "windows")
))]
#[must_use]
fn memcached(self, dsn: impl Into<String>) -> Self;
#[cfg(all(
feature = "redis-client",
any(target_os = "linux", target_os = "macos", target_os = "windows")
))]
#[must_use]
fn redis(self, dsn: impl Into<String>) -> Self;
#[cfg(all(
feature = "redis-client",
any(target_os = "linux", target_os = "macos", target_os = "windows")
))]
#[must_use]
fn valkey(self, dsn: impl Into<String>) -> Self;
#[cfg(all(
feature = "pgwire-client",
any(target_os = "linux", target_os = "macos", target_os = "windows")
))]
#[must_use]
fn pgwire(self, dsn: impl Into<String>) -> Self;
}
impl ClientProtocolExt for ClientBuilder {
fn http(self, url: impl Into<String>) -> Self {
self.set("http", url.into())
}
fn https(self, url: impl Into<String>) -> Self {
self.set("http", url.into())
}
fn grpc(self, url: impl Into<String>) -> Self {
self.set("grpc", url.into())
}
#[cfg(all(
feature = "kafka-client",
any(target_os = "linux", target_os = "macos", target_os = "windows")
))]
fn kafka(self, dsn: impl Into<String>) -> Self {
self.protocol(crate::upstreams::kafka::KafkaClientProtocol::dsn(dsn))
}
#[cfg(all(
feature = "mqtt-client",
any(target_os = "linux", target_os = "macos", target_os = "windows")
))]
fn mqtt(self, dsn: impl Into<String>) -> Self {
self.protocol(crate::upstreams::mqtt::MqttClientProtocol::dsn(dsn))
}
#[cfg(all(
feature = "amqp-client",
any(target_os = "linux", target_os = "macos", target_os = "windows")
))]
fn amqp(self, dsn: impl Into<String>) -> Self {
self.protocol(crate::upstreams::amqp::AmqpClientProtocol::dsn(dsn))
}
#[cfg(all(
feature = "dns-client",
any(target_os = "linux", target_os = "macos", target_os = "windows")
))]
fn dns(self, dsn: impl Into<String>) -> Self {
self.protocol(crate::upstreams::dns::DnsClientProtocol::dsn(dsn))
}
#[cfg(all(
feature = "memcached-client",
any(target_os = "linux", target_os = "macos", target_os = "windows")
))]
fn memcached(self, dsn: impl Into<String>) -> Self {
self.protocol(crate::upstreams::memcached::MemcachedClientProtocol::dsn(
dsn,
))
}
#[cfg(all(
feature = "redis-client",
any(target_os = "linux", target_os = "macos", target_os = "windows")
))]
fn redis(self, dsn: impl Into<String>) -> Self {
self.protocol(crate::upstreams::redis::RedisClientProtocol::dsn(dsn))
}
#[cfg(all(
feature = "redis-client",
any(target_os = "linux", target_os = "macos", target_os = "windows")
))]
fn valkey(self, dsn: impl Into<String>) -> Self {
self.redis(dsn)
}
#[cfg(all(
feature = "pgwire-client",
any(target_os = "linux", target_os = "macos", target_os = "windows")
))]
fn pgwire(self, dsn: impl Into<String>) -> Self {
self.protocol(crate::upstreams::pgwire::PgwireClientProtocol::dsn(dsn))
}
}