MCPcopy Create free account
hub / github.com/chirpstack/chirpstack / setup

Function setup

chirpstack/src/storage/mod.rs:113–150  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

111}
112
113pub async fn setup() -> Result<()> {
114 let conf = config::get();
115
116 #[cfg(feature = "postgres")]
117 {
118 postgres::setup(&conf.postgresql)?;
119 }
120 #[cfg(feature = "sqlite")]
121 {
122 sqlite::setup(&conf.sqlite)?;
123 }
124 run_db_migrations().await?;
125
126 info!("Setting up Redis client");
127 if conf.redis.cluster {
128 let pool = deadpool_redis::cluster::Config::from_urls(conf.redis.servers.clone())
129 .builder()?
130 .max_size(conf.redis.max_open_connections as usize)
131 .build()?;
132 set_async_redis_pool(AsyncRedisPool::ClusterClient(pool)).await;
133 } else {
134 let pool = deadpool_redis::Config::from_url(conf.redis.servers[0].clone())
135 .builder()?
136 .max_size(conf.redis.max_open_connections as usize)
137 .build()?;
138 set_async_redis_pool(AsyncRedisPool::Client(pool)).await;
139 }
140
141 if !conf.redis.key_prefix.is_empty() {
142 info!(prefix = %conf.redis.key_prefix, "Setting Redis prefix");
143 REDIS_PREFIX
144 .write()
145 .unwrap()
146 .clone_from(&conf.redis.key_prefix);
147 }
148
149 Ok(())
150}
151
152async fn get_async_redis_pool() -> Result<AsyncRedisPool> {
153 let pool_r = ASYNC_REDIS_POOL.read().await;

Callers

nothing calls this directly

Calls 5

run_db_migrationsFunction · 0.85
set_async_redis_poolFunction · 0.85
ClientClass · 0.85
unwrapMethod · 0.80
getFunction · 0.70

Tested by

no test coverage detected