-// TODO: store this in context? but its only used in this crate, no need to expose it elsewhere
-// TODO this singleton needs to be redone to account for live data.
-async fn local_instance(context: &LemmyContext) -> &'static LocalInstance {
- static LOCAL_INSTANCE: OnceCell<LocalInstance> = OnceCell::const_new();
- LOCAL_INSTANCE
- .get_or_init(|| async {
- // Local site may be missing
- let local_site = &LocalSite::read(context.pool()).await;
- let worker_count = local_site
- .as_ref()
- .map(|l| l.federation_worker_count)
- .unwrap_or(64) as u64;
-
- let settings = InstanceSettings::builder()
- .http_fetch_retry_limit(FEDERATION_HTTP_FETCH_LIMIT)
- .worker_count(worker_count)
- .debug(cfg!(debug_assertions))
- .http_signature_compat(true)
- .url_verifier(Box::new(VerifyUrlData(context.clone())))
- .build()
- .expect("configure federation");
- LocalInstance::new(
- context.settings().hostname.clone(),
- context.client().clone(),
- settings,
- )
- })
- .await
-}
-