mirror of
https://github.com/storytold/artcraft.git
synced 2026-10-27 12:10:08 -04:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
336b887d63 | ||
|
|
991b573b49 | ||
|
|
9f3a6e4c61 |
Generated
+50
-3
@@ -621,6 +621,12 @@ dependencies = [
|
||||
"zip 0.6.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "arcstr"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "03918c3dbd7701a85c6b9887732e2921175f26c350b4563841d0958c21d57e6d"
|
||||
|
||||
[[package]]
|
||||
name = "arg_enum_proc_macro"
|
||||
version = "0.3.4"
|
||||
@@ -2273,7 +2279,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "35ed6e9d84f0b51a7f52daf1c7d71dd136fd7a3f41a8462b8cdb8c78d920fad4"
|
||||
dependencies = [
|
||||
"bytes 1.10.1",
|
||||
"futures-core",
|
||||
"memchr",
|
||||
"pin-project-lite",
|
||||
"tokio",
|
||||
"tokio-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -9013,12 +9023,41 @@ dependencies = [
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redis"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5dfe20977fe93830c0e9817a16fbf1ed1cfd8d4bba366087a1841d2c6033c251"
|
||||
dependencies = [
|
||||
"arcstr",
|
||||
"bytes 1.10.1",
|
||||
"cfg-if 1.0.0",
|
||||
"combine 4.6.6",
|
||||
"futures-util",
|
||||
"itoa 1.0.11",
|
||||
"num-bigint",
|
||||
"percent-encoding",
|
||||
"pin-project-lite",
|
||||
"r2d2",
|
||||
"rustls 0.23.13",
|
||||
"rustls-native-certs 0.8.0",
|
||||
"ryu",
|
||||
"sha1_smol",
|
||||
"socket2 0.6.0",
|
||||
"tokio",
|
||||
"tokio-rustls 0.26.0",
|
||||
"tokio-util",
|
||||
"url",
|
||||
"xxhash-rust",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redis_caching"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"errors",
|
||||
"r2d2_redis",
|
||||
"r2d2",
|
||||
"redis 1.0.2",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
@@ -9046,7 +9085,8 @@ dependencies = [
|
||||
"chrono",
|
||||
"enums",
|
||||
"errors",
|
||||
"r2d2_redis",
|
||||
"r2d2",
|
||||
"redis 1.0.2",
|
||||
"serde",
|
||||
"tokens",
|
||||
"url",
|
||||
@@ -10961,8 +11001,9 @@ dependencies = [
|
||||
"password",
|
||||
"primitives",
|
||||
"prompt_engineering",
|
||||
"r2d2_redis",
|
||||
"r2d2",
|
||||
"rand 0.9.1",
|
||||
"redis 1.0.2",
|
||||
"redis_caching",
|
||||
"redis_common",
|
||||
"redis_schema",
|
||||
@@ -14520,6 +14561,12 @@ dependencies = [
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "xxhash-rust"
|
||||
version = "0.8.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fdd20c5420375476fbd4394763288da7eb0cc0b8c11deed431a91562af7335d3"
|
||||
|
||||
[[package]]
|
||||
name = "yansi"
|
||||
version = "1.0.1"
|
||||
|
||||
@@ -248,7 +248,9 @@ hex-literal = "1.0.0"
|
||||
indexmap = "2.9.0"
|
||||
log = "0.4.27"
|
||||
once_cell = "1.21.3"
|
||||
r2d2 = "0.8.10"
|
||||
rand = "0.9.1"
|
||||
redis = { version = "1.0.2", features = ["r2d2", "tokio-rustls-comp"] }
|
||||
regex = "1.12.2"
|
||||
reqwest = { version = "0.12.23", default-features = false, features = [ "charset", "http2", "system-proxy", "json", "cookies", "rustls-tls" ] }
|
||||
reqwest-websocket = { version = "0.5.0" }
|
||||
|
||||
@@ -16,19 +16,20 @@ path = "src/lib.rs"
|
||||
normal = ["workspace-build-acceleration"]
|
||||
|
||||
[dependencies]
|
||||
# Internal
|
||||
errors = { path = "../../errors" }
|
||||
|
||||
# Workspace hack (faster compile times)
|
||||
workspace-build-acceleration = { version = "0.1", path = "../../../workspace-build-acceleration" }
|
||||
workspace-build-acceleration.workspace = true
|
||||
|
||||
# Internal
|
||||
errors.workspace = true
|
||||
|
||||
# Redis Database
|
||||
r2d2_redis = "0.14.0"
|
||||
r2d2.workspace = true
|
||||
redis.workspace = true
|
||||
|
||||
# Serialization
|
||||
serde = "1.0.125"
|
||||
serde_derive = "1.0.125"
|
||||
serde_json = "1.0.108"
|
||||
serde.workspace = true
|
||||
serde_derive.workspace = true
|
||||
serde_json.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
# None yet
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
use std::future::Future;
|
||||
|
||||
use r2d2_redis::r2d2::{Pool, PooledConnection};
|
||||
use r2d2_redis::redis::Commands;
|
||||
use r2d2_redis::RedisConnectionManager;
|
||||
use r2d2::{Pool, PooledConnection};
|
||||
use redis::{Client, Commands};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::future::Future;
|
||||
|
||||
use errors::AnyhowResult;
|
||||
|
||||
const DEFAULT_TTL_SECONDS : usize = 60;
|
||||
const DEFAULT_TTL_SECONDS : u64 = 60;
|
||||
|
||||
const REDIS_KEY_PREFIX : &str = "_c";
|
||||
|
||||
@@ -17,16 +15,16 @@ const REDIS_KEY_PREFIX : &str = "_c";
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct RedisTtlCache {
|
||||
redis_pool: Pool<RedisConnectionManager>,
|
||||
default_key_ttl: usize,
|
||||
redis_pool: Pool<Client>,
|
||||
default_key_ttl: u64,
|
||||
}
|
||||
|
||||
impl RedisTtlCache {
|
||||
pub fn new(redis_pool: Pool<RedisConnectionManager>) -> Self {
|
||||
pub fn new(redis_pool: Pool<Client>) -> Self {
|
||||
Self::new_with_ttl(redis_pool, DEFAULT_TTL_SECONDS)
|
||||
}
|
||||
|
||||
pub fn new_with_ttl(redis_pool: Pool<RedisConnectionManager>, key_ttl: usize) -> Self {
|
||||
pub fn new_with_ttl(redis_pool: Pool<Client>, key_ttl: u64) -> Self {
|
||||
Self {
|
||||
redis_pool,
|
||||
default_key_ttl: key_ttl,
|
||||
@@ -43,8 +41,8 @@ impl RedisTtlCache {
|
||||
}
|
||||
|
||||
pub struct RedisTtlCacheConnection {
|
||||
redis_connection: PooledConnection<RedisConnectionManager>,
|
||||
default_key_ttl: usize,
|
||||
redis_connection: PooledConnection<Client>,
|
||||
default_key_ttl: u64,
|
||||
}
|
||||
|
||||
impl RedisTtlCacheConnection {
|
||||
|
||||
@@ -17,20 +17,22 @@ normal = ["workspace-build-acceleration"]
|
||||
|
||||
[dependencies]
|
||||
# Workspace hack (faster compile times)
|
||||
workspace-build-acceleration = { workspace = true }
|
||||
workspace-build-acceleration.workspace = true
|
||||
|
||||
# Internal
|
||||
enums = { workspace = true }
|
||||
errors = { workspace = true }
|
||||
tokens = { workspace = true }
|
||||
enums.workspace = true
|
||||
errors.workspace = true
|
||||
tokens.workspace = true
|
||||
|
||||
# External
|
||||
chrono = { workspace = true }
|
||||
chrono.workspace = true
|
||||
|
||||
# Redis
|
||||
r2d2_redis = "0.14.0"
|
||||
url = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
#r2d2_redis = "0.14.0"
|
||||
r2d2.workspace = true
|
||||
redis.workspace = true
|
||||
url.workspace = true
|
||||
serde.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
# None yet
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
use std::ops::Add;
|
||||
|
||||
use chrono::Utc;
|
||||
use r2d2_redis::r2d2::PooledConnection;
|
||||
use r2d2_redis::redis::Commands;
|
||||
use r2d2_redis::RedisConnectionManager;
|
||||
use r2d2::PooledConnection;
|
||||
use redis::{Client, Commands};
|
||||
|
||||
use errors::AnyhowResult;
|
||||
use crate::keys::premium::premium_avt_redis_key::PremiumAvtRedisKey;
|
||||
use crate::keys::premium::premium_user_redis_key::PremiumUserRedisKey;
|
||||
use crate::payloads::premium::inner_state::premium_payload::PremiumPayload;
|
||||
use crate::traits::hkey_store_adapter::HkeyStoreAdapter;
|
||||
use errors::AnyhowResult;
|
||||
|
||||
pub struct PremiumAvtPayload {
|
||||
pub key: PremiumAvtRedisKey,
|
||||
@@ -25,7 +24,7 @@ impl PremiumAvtPayload {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn read_from_redis(key: PremiumAvtRedisKey, redis: &mut PooledConnection<RedisConnectionManager>) -> AnyhowResult<Self> {
|
||||
pub fn read_from_redis(key: PremiumAvtRedisKey, redis: &mut PooledConnection<Client>) -> AnyhowResult<Self> {
|
||||
let payload = PremiumPayload::read_from_redis(key.as_str(), redis)?;
|
||||
Ok(Self {
|
||||
key,
|
||||
@@ -33,16 +32,16 @@ impl PremiumAvtPayload {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn persist_to_redis_with_expiry(&self, redis: &mut PooledConnection<RedisConnectionManager>) -> AnyhowResult<()> {
|
||||
pub fn persist_to_redis_with_expiry(&self, redis: &mut PooledConnection<Client>) -> AnyhowResult<()> {
|
||||
self.payload.persist_to_redis(self.key.as_str(), redis)?;
|
||||
self.set_key_expiry(redis)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn set_key_expiry(&self, redis: &mut PooledConnection<RedisConnectionManager>) -> AnyhowResult<()> {
|
||||
pub fn set_key_expiry(&self, redis: &mut PooledConnection<Client>) -> AnyhowResult<()> {
|
||||
let expire_at= Utc::now()
|
||||
.add(PremiumUserRedisKey::get_redis_ttl())
|
||||
.timestamp() as usize;
|
||||
.timestamp() as i64;
|
||||
redis.expire_at::<_, ()>(self.key.as_str(), expire_at)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
+7
-7
@@ -1,9 +1,9 @@
|
||||
use std::ops::Add;
|
||||
|
||||
use chrono::Utc;
|
||||
use r2d2_redis::r2d2::PooledConnection;
|
||||
use r2d2_redis::redis::Commands;
|
||||
use r2d2_redis::RedisConnectionManager;
|
||||
use r2d2::PooledConnection;
|
||||
use redis::Client;
|
||||
use redis::Commands;
|
||||
|
||||
use errors::AnyhowResult;
|
||||
|
||||
@@ -26,7 +26,7 @@ impl PremiumIpAddressPayload {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn read_from_redis(key: PremiumIpAddressRedisKey, redis: &mut PooledConnection<RedisConnectionManager>) -> AnyhowResult<Self> {
|
||||
pub fn read_from_redis(key: PremiumIpAddressRedisKey, redis: &mut PooledConnection<Client>) -> AnyhowResult<Self> {
|
||||
let payload = PremiumPayload::read_from_redis(key.as_str(), redis)?;
|
||||
Ok(Self {
|
||||
key,
|
||||
@@ -34,16 +34,16 @@ impl PremiumIpAddressPayload {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn persist_to_redis_with_expiry(&self, redis: &mut PooledConnection<RedisConnectionManager>) -> AnyhowResult<()> {
|
||||
pub fn persist_to_redis_with_expiry(&self, redis: &mut PooledConnection<Client>) -> AnyhowResult<()> {
|
||||
self.payload.persist_to_redis(self.key.as_str(), redis)?;
|
||||
self.set_key_expiry(redis)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn set_key_expiry(&self, redis: &mut PooledConnection<RedisConnectionManager>) -> AnyhowResult<()> {
|
||||
pub fn set_key_expiry(&self, redis: &mut PooledConnection<Client>) -> AnyhowResult<()> {
|
||||
let expire_at= Utc::now()
|
||||
.add(PremiumUserRedisKey::get_redis_ttl())
|
||||
.timestamp() as usize;
|
||||
.timestamp() as i64;
|
||||
redis.expire_at::<_, ()>(self.key.as_str(), expire_at)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use std::ops::Add;
|
||||
|
||||
use chrono::Utc;
|
||||
use r2d2_redis::r2d2::PooledConnection;
|
||||
use r2d2_redis::redis::Commands;
|
||||
use r2d2_redis::RedisConnectionManager;
|
||||
use r2d2::PooledConnection;
|
||||
use redis::Client;
|
||||
use redis::Commands;
|
||||
|
||||
use errors::AnyhowResult;
|
||||
|
||||
@@ -25,7 +25,7 @@ impl PremiumUserPayload {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn read_from_redis(key: PremiumUserRedisKey, redis: &mut PooledConnection<RedisConnectionManager>) -> AnyhowResult<Self> {
|
||||
pub fn read_from_redis(key: PremiumUserRedisKey, redis: &mut PooledConnection<Client>) -> AnyhowResult<Self> {
|
||||
let payload = PremiumPayload::read_from_redis(key.as_str(), redis)?;
|
||||
Ok(Self {
|
||||
key,
|
||||
@@ -33,16 +33,16 @@ impl PremiumUserPayload {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn persist_to_redis_with_expiry(&self, redis: &mut PooledConnection<RedisConnectionManager>) -> AnyhowResult<()> {
|
||||
pub fn persist_to_redis_with_expiry(&self, redis: &mut PooledConnection<Client>) -> AnyhowResult<()> {
|
||||
self.payload.persist_to_redis(self.key.as_str(), redis)?;
|
||||
self.set_key_expiry(redis)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn set_key_expiry(&self, redis: &mut PooledConnection<RedisConnectionManager>) -> AnyhowResult<()> {
|
||||
pub fn set_key_expiry(&self, redis: &mut PooledConnection<Client>) -> AnyhowResult<()> {
|
||||
let expire_at= Utc::now()
|
||||
.add(PremiumUserRedisKey::get_redis_ttl())
|
||||
.timestamp() as usize;
|
||||
.timestamp() as i64;
|
||||
redis.expire_at::<_, ()>(self.key.as_str(), expire_at)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use r2d2_redis::r2d2::PooledConnection;
|
||||
use r2d2_redis::redis::Commands;
|
||||
use r2d2_redis::RedisConnectionManager;
|
||||
use r2d2::PooledConnection;
|
||||
use redis::{Client, Commands};
|
||||
|
||||
use errors::AnyhowResult;
|
||||
|
||||
pub trait HkeyStoreAdapter {
|
||||
|
||||
fn read_from_redis(redis_key: &str, redis: &mut PooledConnection<RedisConnectionManager>) -> AnyhowResult<Self> where Self: Sized {
|
||||
fn read_from_redis(redis_key: &str, redis: &mut PooledConnection<Client>) -> AnyhowResult<Self> where Self: Sized {
|
||||
let usage_map : HashMap<String, String> = redis.hgetall(redis_key)?;
|
||||
let hydrated = Self::hydrate_from_vec(usage_map)?;
|
||||
Ok(hydrated)
|
||||
}
|
||||
|
||||
fn persist_to_redis(&self, redis_key: &str, redis: &mut PooledConnection<RedisConnectionManager>) -> AnyhowResult<()> {
|
||||
fn persist_to_redis(&self, redis_key: &str, redis: &mut PooledConnection<Client>) -> AnyhowResult<()> {
|
||||
let map = self.serialize_payload()?;
|
||||
redis.hset_multiple::<_, _, _, ()>(redis_key, &map)?;
|
||||
Ok(())
|
||||
|
||||
@@ -124,7 +124,8 @@ sqlx = { version = "0.7.4", features = [ "mysql", "runtime-tokio-rustls", "chron
|
||||
|
||||
# Redis Database
|
||||
limitation = { path = "../../../vendor/limitation" }
|
||||
r2d2_redis = "0.14.0"
|
||||
r2d2.workspace = true
|
||||
redis.workspace = true
|
||||
|
||||
# Elasticsearch
|
||||
elasticsearch = { version = "8.5.0-alpha.1", default-features = false, features = ["rustls-tls"] }
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ use actix_web::error::ResponseError;
|
||||
use actix_web::http::StatusCode;
|
||||
use actix_web::{web, HttpRequest, HttpResponse};
|
||||
use log::{info, warn};
|
||||
use r2d2_redis::redis::Commands;
|
||||
use redis::Commands;
|
||||
|
||||
use enums::common::visibility::Visibility;
|
||||
use http_server_common::request::get_request_ip::get_request_ip;
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ use actix_web::web::BytesMut;
|
||||
use actix_web::{web, HttpRequest, HttpResponse, ResponseError};
|
||||
use futures::TryStreamExt;
|
||||
use log::{error, info, warn};
|
||||
use r2d2_redis::redis::Commands;
|
||||
use redis::Commands;
|
||||
|
||||
use enums::common::visibility::Visibility;
|
||||
use http_server_common::request::get_request_ip::get_request_ip;
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ use actix_web::web::Path;
|
||||
use actix_web::{web, HttpMessage, HttpRequest, HttpResponse};
|
||||
use chrono::{DateTime, Utc};
|
||||
use log::warn;
|
||||
use r2d2_redis::redis::Commands;
|
||||
use redis::Commands;
|
||||
|
||||
use mysql_queries::queries::w2l::w2l_inference_jobs::get_w2l_inference_job_status::get_w2l_inference_job_status;
|
||||
use redis_common::redis_keys::RedisKeys;
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ use actix_web::web::Path;
|
||||
use actix_web::{web, HttpMessage, HttpRequest, HttpResponse};
|
||||
use derive_more::Display;
|
||||
use log::warn;
|
||||
use r2d2_redis::redis::Commands;
|
||||
use redis::Commands;
|
||||
|
||||
use redis_common::redis_keys::RedisKeys;
|
||||
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ use actix_web::{web, HttpMessage, HttpRequest, HttpResponse};
|
||||
use chrono::{DateTime, Utc};
|
||||
use derive_more::Display;
|
||||
use log::warn;
|
||||
use r2d2_redis::redis::Commands;
|
||||
use redis::Commands;
|
||||
|
||||
use mysql_queries::queries::w2l::w2l_template_upload_jobs::get_w2l_template_upload_job_status::get_w2l_template_upload_job_status;
|
||||
use redis_common::redis_keys::RedisKeys;
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ use actix_web::web::{Json, Path};
|
||||
use actix_web::{web, HttpRequest, HttpResponse};
|
||||
use chrono::{DateTime, Utc};
|
||||
use log::error;
|
||||
use r2d2_redis::redis::{Commands, RedisResult};
|
||||
use redis::{Commands, RedisResult};
|
||||
use utoipa::ToSchema;
|
||||
|
||||
use enums::by_table::generic_inference_jobs::frontend_failure_category::FrontendFailureCategory;
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ use actix_web::{
|
||||
use actix_web_actors::ws;
|
||||
use chrono::{DateTime, Utc};
|
||||
use log::error;
|
||||
use r2d2_redis::redis::{Commands, RedisResult};
|
||||
use redis::{Commands, RedisResult};
|
||||
use utoipa::ToSchema;
|
||||
use web::Data;
|
||||
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ use actix_web::web::Path;
|
||||
use actix_web::{web, HttpMessage, HttpRequest, HttpResponse};
|
||||
use chrono::{DateTime, Utc};
|
||||
use log::warn;
|
||||
use r2d2_redis::redis::Commands;
|
||||
use redis::Commands;
|
||||
|
||||
use http_server_common::response::serialize_as_json_error::serialize_as_json_error;
|
||||
use mysql_queries::queries::generic_download::web::get_generic_download_job_status::get_generic_download_job_status;
|
||||
|
||||
+2
-2
@@ -29,7 +29,7 @@ use enums::no_table::style_transfer::style_transfer_name::StyleTransferName;
|
||||
use log::error;
|
||||
use mysql_queries::queries::generic_inference::web::batch_get_inference_job_status::batch_get_inference_job_status;
|
||||
use mysql_queries::queries::generic_inference::web::job_status::GenericInferenceJobStatus;
|
||||
use r2d2_redis::redis::Commands;
|
||||
use redis::Commands;
|
||||
use redis_common::redis_keys::RedisKeys;
|
||||
use server_environment::ServerEnvironment;
|
||||
use tokens::tokens::generic_inference_jobs::InferenceJobToken;
|
||||
@@ -39,7 +39,7 @@ use utoipa::{IntoParams, ToSchema};
|
||||
/// maintained a keepalive. This prevents wasted work when users who are unlikely to return
|
||||
/// navigate away. Premium users have accounts and can always return to the site, so they
|
||||
/// typically do not require keepalive.
|
||||
const JOB_KEEPALIVE_TTL_SECONDS : usize = 60 * 3;
|
||||
const JOB_KEEPALIVE_TTL_SECONDS : u64 = 60 * 3;
|
||||
|
||||
#[derive(Deserialize, ToSchema, IntoParams)]
|
||||
pub struct BatchGetInferenceJobStatusQueryParams {
|
||||
|
||||
+2
-2
@@ -27,7 +27,7 @@ use enums::no_table::style_transfer::style_transfer_name::StyleTransferName;
|
||||
use log::error;
|
||||
use mysql_queries::queries::generic_inference::web::get_inference_job_status::get_inference_job_status;
|
||||
use mysql_queries::queries::generic_inference::web::job_status::GenericInferenceJobStatus;
|
||||
use r2d2_redis::redis::{Commands, RedisResult};
|
||||
use redis::{Commands, RedisResult};
|
||||
use redis_common::redis_keys::RedisKeys;
|
||||
use server_environment::ServerEnvironment;
|
||||
use tokens::tokens::generic_inference_jobs::InferenceJobToken;
|
||||
@@ -37,7 +37,7 @@ use utoipa::ToSchema;
|
||||
/// maintained a keepalive. This prevents wasted work when users who are unlikely to return
|
||||
/// navigate away. Premium users have accounts and can always return to the site, so they
|
||||
/// typically do not require keepalive.
|
||||
const JOB_KEEPALIVE_TTL_SECONDS : usize = 60 * 3;
|
||||
const JOB_KEEPALIVE_TTL_SECONDS : u64 = 60 * 3;
|
||||
|
||||
/// For the URL PathInfo
|
||||
#[derive(Deserialize, ToSchema)]
|
||||
|
||||
+2
-2
@@ -29,7 +29,7 @@ use log::{error, warn};
|
||||
use mysql_queries::queries::generic_inference::web::job_status::GenericInferenceJobStatus;
|
||||
use mysql_queries::queries::generic_inference::web::list_session_jobs::{list_session_jobs_from_connection, ListSessionJobsForUserArgs, SessionUser};
|
||||
use primitives::numerics::i64_to_u64_zero_clamped::i64_to_u64_zero_clamped;
|
||||
use r2d2_redis::redis::Commands;
|
||||
use redis::Commands;
|
||||
use redis_common::redis_keys::RedisKeys;
|
||||
use server_environment::ServerEnvironment;
|
||||
use tokens::tokens::generic_inference_jobs::InferenceJobToken;
|
||||
@@ -40,7 +40,7 @@ use utoipa::{IntoParams, ToSchema};
|
||||
/// maintained a keepalive. This prevents wasted work when users who are unlikely to return
|
||||
/// navigate away. Premium users have accounts and can always return to the site, so they
|
||||
/// typically do not require keepalive.
|
||||
const JOB_KEEPALIVE_TTL_SECONDS : usize = 60 * 3;
|
||||
const JOB_KEEPALIVE_TTL_SECONDS : u64 = 60 * 3;
|
||||
|
||||
#[derive(Debug, ToSchema)]
|
||||
pub enum ListSessionJobsError {
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ use enums::no_table::style_transfer::style_transfer_name::StyleTransferName;
|
||||
use enums_public::by_table::media_files::public_media_file_model_type::PublicMediaFileModelType;
|
||||
use log::{debug, error, warn};
|
||||
use mysql_queries::queries::media_files::get::batch_get_media_files_by_tokens::batch_get_media_files_by_tokens;
|
||||
use r2d2_redis::redis::Commands;
|
||||
use redis::Commands;
|
||||
use tokens::tokens::media_files::MediaFileToken;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
|
||||
+2
-3
@@ -8,8 +8,7 @@ use actix_web::http::StatusCode;
|
||||
use actix_web::web::{Data, Json, Path};
|
||||
use actix_web::{HttpRequest, HttpResponse};
|
||||
use log::warn;
|
||||
use r2d2_redis::redis::Commands;
|
||||
use r2d2_redis::{r2d2, RedisConnectionManager};
|
||||
use redis::{Client, Commands};
|
||||
use utoipa::ToSchema;
|
||||
|
||||
use enums::by_table::users::user_feature_flag::UserFeatureFlag;
|
||||
@@ -112,7 +111,7 @@ pub async fn edit_user_feature_flags_handler(
|
||||
request: Json<EditUserFeatureFlagsRequest>,
|
||||
server_state: Data<Arc<ServerState>>,
|
||||
//redis_ttl_cache: Data<RedisTtlCache>,
|
||||
redis_pool: Data<r2d2::Pool<RedisConnectionManager>>,
|
||||
redis_pool: Data<r2d2::Pool<Client>>,
|
||||
) -> Result<HttpResponse, EditUserFeatureFlagsError> {
|
||||
|
||||
let maybe_user_session = server_state
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ use actix_web::http::StatusCode;
|
||||
use actix_web::web::Json;
|
||||
use actix_web::{web, HttpRequest, HttpResponse};
|
||||
use log::{info, warn};
|
||||
use r2d2_redis::redis::Commands;
|
||||
use redis::Commands;
|
||||
use rand::seq::IndexedRandom;
|
||||
use rand::Rng;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ use actix_web::web::Path;
|
||||
use actix_web::{web, HttpMessage, HttpRequest, HttpResponse};
|
||||
use chrono::{DateTime, Utc};
|
||||
use log::error;
|
||||
use r2d2_redis::redis::{Commands, RedisResult};
|
||||
use redis::{Commands, RedisResult};
|
||||
|
||||
use bucket_paths::legacy::typified_paths::public::media_files::bucket_file_path::MediaFileBucketPath;
|
||||
use mysql_queries::queries::generic_inference::web::get_inference_job_status::get_inference_job_status;
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ use actix_web::web::Path;
|
||||
use actix_web::{web, HttpMessage, HttpRequest, HttpResponse};
|
||||
use derive_more::Display;
|
||||
use log::warn;
|
||||
use r2d2_redis::redis::Commands;
|
||||
use redis::Commands;
|
||||
|
||||
use redis_common::redis_keys::RedisKeys;
|
||||
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ use actix_web::{web, HttpMessage, HttpRequest, HttpResponse};
|
||||
use chrono::{DateTime, Utc};
|
||||
use derive_more::Display;
|
||||
use log::{error, warn};
|
||||
use r2d2_redis::redis::Commands;
|
||||
use redis::Commands;
|
||||
|
||||
use mysql_queries::queries::tts::tts_model_upload_jobs::get_tts_model_upload_job_status::get_tts_model_upload_job_status;
|
||||
use redis_common::redis_keys::RedisKeys;
|
||||
|
||||
+5
-6
@@ -12,9 +12,8 @@ use actix_web::web::Path;
|
||||
use actix_web::{web, HttpRequest, HttpResponse};
|
||||
use chrono::{DateTime, Utc};
|
||||
use log::{error, warn};
|
||||
use r2d2_redis::r2d2::PooledConnection;
|
||||
use r2d2_redis::redis::Commands;
|
||||
use r2d2_redis::{r2d2, RedisConnectionManager};
|
||||
use r2d2::PooledConnection;
|
||||
use redis::{Client, Commands};
|
||||
use sqlx::MySqlPool;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
@@ -140,7 +139,7 @@ pub async fn get_profile_handler(
|
||||
http_request: HttpRequest,
|
||||
path: Path<GetProfilePathInfo>,
|
||||
mysql_pool: web::Data<MySqlPool>,
|
||||
redis_pool: web::Data<r2d2::Pool<RedisConnectionManager>>,
|
||||
redis_pool: web::Data<r2d2::Pool<Client>>,
|
||||
session_checker: web::Data<SessionChecker>,
|
||||
) -> Result<HttpResponse, ProfileError>
|
||||
{
|
||||
@@ -245,7 +244,7 @@ pub async fn get_profile_handler(
|
||||
if store_in_cache {
|
||||
if let Some(redis) = maybe_redis.as_mut() {
|
||||
if let Ok(redis_payload) = serde_json::to_string(&user_data) {
|
||||
const SECONDS : usize = 60;
|
||||
const SECONDS : u64 = 60;
|
||||
// NB: Compiler can't figure out the throwaway result type
|
||||
let _r : Option<String> = redis.set_ex(&cache_key, redis_payload, SECONDS).ok();
|
||||
}
|
||||
@@ -343,7 +342,7 @@ pub (crate) struct RedisCacheData {
|
||||
// TODO: Async
|
||||
pub (crate) fn try_get_user_from_redis_cache(
|
||||
cache_key: &str,
|
||||
redis: &mut PooledConnection<RedisConnectionManager>,
|
||||
redis: &mut PooledConnection<Client>,
|
||||
) -> Option<RedisCacheData> {
|
||||
|
||||
let results : Option<String> = redis.get(cache_key).ok().flatten();
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ use actix_web::http::StatusCode;
|
||||
use actix_web::web::Json;
|
||||
use actix_web::{web, HttpRequest, HttpResponse};
|
||||
use log::{error, info, warn};
|
||||
use r2d2_redis::redis::Commands;
|
||||
use redis::Commands;
|
||||
use sqlx::pool::PoolConnection;
|
||||
use sqlx::MySql;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@ use actix_web::http::StatusCode;
|
||||
use actix_web::{web, HttpRequest, HttpResponse};
|
||||
use chrono::{DateTime, Utc};
|
||||
use log::{debug, error, warn};
|
||||
use r2d2_redis::redis::Commands;
|
||||
use redis::Commands;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
use bucket_paths::legacy::typified_paths::public::media_files::bucket_file_path::MediaFileBucketPath;
|
||||
@@ -126,7 +126,7 @@ pub async fn list_pinned_weights_handler(
|
||||
.unwrap_or_else(|| "".to_string())
|
||||
.split(",")
|
||||
.into_iter()
|
||||
.map(|item| item.trim())
|
||||
.map(|item: &str| item.trim())
|
||||
.filter(|item| !item.is_empty())
|
||||
.map(|item| ModelWeightToken::new_from_str(item))
|
||||
.collect::<Vec<ModelWeightToken>>();
|
||||
|
||||
@@ -29,8 +29,7 @@ use chrono::Utc;
|
||||
use elasticsearch::http::transport::Transport;
|
||||
use elasticsearch::Elasticsearch;
|
||||
use log::info;
|
||||
use r2d2_redis::r2d2;
|
||||
use r2d2_redis::RedisConnectionManager;
|
||||
use redis::Client;
|
||||
use tokio::runtime::Runtime;
|
||||
|
||||
use actix_cors_configs::cors::build_cors_config;
|
||||
@@ -160,7 +159,7 @@ async fn main() -> AnyhowResult<()> {
|
||||
|
||||
info!("Connected to redis...");
|
||||
|
||||
let redis_manager = RedisConnectionManager::new(
|
||||
let redis_manager = Client::open(
|
||||
common_env.redis_0_connection_string.clone())?;
|
||||
|
||||
let redis_pool = r2d2::Pool::builder()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use chrono::{DateTime, Utc};
|
||||
use elasticsearch::Elasticsearch;
|
||||
use r2d2_redis::{r2d2, RedisConnectionManager};
|
||||
use redis::Client;
|
||||
use sqlx::MySqlPool;
|
||||
|
||||
use actix_helpers::middleware::banned_cidr_filter::banned_cidr_set::BannedCidrSet;
|
||||
@@ -75,7 +75,7 @@ pub struct ServerState {
|
||||
|
||||
pub elasticsearch: Elasticsearch,
|
||||
|
||||
pub redis_pool: r2d2::Pool<RedisConnectionManager>,
|
||||
pub redis_pool: r2d2::Pool<Client>,
|
||||
pub redis_ttl_cache: RedisTtlCache,
|
||||
|
||||
pub redis_rate_limiters: RedisRateLimiters,
|
||||
|
||||
Reference in New Issue
Block a user