mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-09 08:03:50 +00:00
include instance uid in ee usage (#7347)
* include instance uid in ee usage * Update ee-repo-ref.txt --------- Co-authored-by: windmill-internal-app[bot] <windmill-internal-app[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
windmill-internal-app[bot]
parent
c6c7f3415a
commit
c57c5547db
@@ -1 +1 @@
|
||||
ffc3e065de448f94d2cd6b39d4aac917e1a77307
|
||||
55e8296c3758b031e50d7ebdaef7c33666f02385
|
||||
|
||||
@@ -338,7 +338,7 @@ pub async fn http_get_from_hub(
|
||||
db: Option<&Pool<Postgres>>,
|
||||
) -> Result<reqwest::Response> {
|
||||
let uid = match db {
|
||||
Some(db) => match get_uid(db).await {
|
||||
Some(db) => match get_license_id_or_uid(db).await {
|
||||
Ok(uid) => Some(uid),
|
||||
Err(err) => {
|
||||
tracing::info!("No valid uid found: {}", err);
|
||||
@@ -393,23 +393,43 @@ pub fn calculate_hash(s: &str) -> String {
|
||||
format!("{:x}", hasher.finalize())
|
||||
}
|
||||
|
||||
pub async fn get_uid<'c, E: sqlx::Executor<'c, Database = Postgres>>(db: E) -> Result<String> {
|
||||
let mut uid = LICENSE_KEY_ID.read().await.clone();
|
||||
pub async fn get_license_id_or_uid<'c, E: sqlx::Executor<'c, Database = Postgres>>(
|
||||
db: E,
|
||||
) -> Result<String> {
|
||||
let license_id = LICENSE_KEY_ID.read().await.clone();
|
||||
|
||||
if uid == "" {
|
||||
let uid_value = sqlx::query_scalar!(
|
||||
"SELECT value FROM global_settings WHERE name = $1",
|
||||
UNIQUE_ID_SETTING
|
||||
)
|
||||
.fetch_one(db)
|
||||
.await?;
|
||||
|
||||
uid = serde_json::from_value::<String>(uid_value).map_err(to_anyhow)?;
|
||||
if license_id.is_empty() {
|
||||
get_instance_uid(db).await
|
||||
} else {
|
||||
Ok(license_id)
|
||||
}
|
||||
}
|
||||
|
||||
async fn get_instance_uid<'c, E: sqlx::Executor<'c, Database = Postgres>>(db: E) -> Result<String> {
|
||||
let uid_value = sqlx::query_scalar!(
|
||||
"SELECT value FROM global_settings WHERE name = $1",
|
||||
UNIQUE_ID_SETTING
|
||||
)
|
||||
.fetch_one(db)
|
||||
.await?;
|
||||
|
||||
let uid = serde_json::from_value::<String>(uid_value).map_err(to_anyhow)?;
|
||||
|
||||
Ok(uid)
|
||||
}
|
||||
|
||||
pub async fn get_telemetry_ids<'c, E: sqlx::Executor<'c, Database = Postgres>>(
|
||||
db: E,
|
||||
) -> Result<(String, String)> {
|
||||
let license_id = LICENSE_KEY_ID.read().await.clone();
|
||||
let instance_uid = get_instance_uid(db).await?;
|
||||
if license_id.is_empty() {
|
||||
Ok((instance_uid.clone(), instance_uid))
|
||||
} else {
|
||||
Ok((license_id, instance_uid))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn map_string_to_number(s: &str, max_number: u64) -> u64 {
|
||||
use std::collections::hash_map::DefaultHasher;
|
||||
use std::hash::{Hash, Hasher};
|
||||
|
||||
Reference in New Issue
Block a user