mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 12:11:56 +00:00
move MAU tracking back to registry
This commit is contained in:
@@ -10,6 +10,7 @@ use reqwest::{Client, Proxy};
|
||||
use rpc_toolkit::yajrc::RpcError;
|
||||
use rpc_toolkit::{CallRemote, Context, Empty};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::PgPool;
|
||||
use tokio::sync::broadcast::Sender;
|
||||
use tracing::instrument;
|
||||
use url::Url;
|
||||
@@ -37,6 +38,8 @@ pub struct RegistryConfig {
|
||||
pub tor_proxy: Option<Url>,
|
||||
#[arg(short = 'd', long = "datadir")]
|
||||
pub datadir: Option<PathBuf>,
|
||||
#[arg(short = 'u', long = "pg-connection-url")]
|
||||
pub pg_connection_url: Option<String>,
|
||||
}
|
||||
impl ContextConfig for RegistryConfig {
|
||||
fn next(&mut self) -> Option<PathBuf> {
|
||||
@@ -67,6 +70,7 @@ pub struct RegistryContextSeed {
|
||||
pub rpc_continuations: RpcContinuations,
|
||||
pub client: Client,
|
||||
pub shutdown: Sender<()>,
|
||||
pub pool: Option<PgPool>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
@@ -94,6 +98,13 @@ impl RegistryContext {
|
||||
.clone()
|
||||
.map(Ok)
|
||||
.unwrap_or_else(|| "socks5h://localhost:9050".parse())?;
|
||||
let pool: Option<PgPool> = match &config.pg_connection_url {
|
||||
Some(url) => match PgPool::connect(url.as_str()).await {
|
||||
Ok(pool) => Some(pool),
|
||||
Err(_) => None,
|
||||
},
|
||||
None => None,
|
||||
};
|
||||
Ok(Self(Arc::new(RegistryContextSeed {
|
||||
hostname: config
|
||||
.hostname
|
||||
@@ -122,6 +133,7 @@ impl RegistryContext {
|
||||
.build()
|
||||
.with_kind(crate::ErrorKind::ParseUrl)?,
|
||||
shutdown,
|
||||
pool,
|
||||
})))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user