| 137 | |
| 138 | impl Integration { |
| 139 | fn new(conf: &Configuration) -> Result<Self> { |
| 140 | info!("Initializing ChirpStack Integration backend"); |
| 141 | |
| 142 | let redis_client = if conf.redis.cluster { |
| 143 | info!("Setting up Redis Cluster client"); |
| 144 | RedisClient::ClusterClient( |
| 145 | redis::cluster::ClusterClientBuilder::new(conf.redis.servers.clone()).build()?, |
| 146 | ) |
| 147 | } else { |
| 148 | info!(server = %conf.redis.servers[0], "Setting up Redis client"); |
| 149 | RedisClient::Client(redis::Client::open(conf.redis.servers[0].clone())?) |
| 150 | }; |
| 151 | |
| 152 | Ok(Integration { |
| 153 | redis_client, |
| 154 | key_prefix: conf.redis.key_prefix.clone(), |
| 155 | consumer_group: conf.redis.consumer_group.clone(), |
| 156 | consumer_name: conf.redis.consumer_name.clone(), |
| 157 | }) |
| 158 | } |
| 159 | |
| 160 | async fn start(&self) -> Result<()> { |
| 161 | info!("Getting Redis connection"); |