mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 01:10:23 +08:00
feat: pass session scope into scheduler cache
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use aether_scheduler_core::{
|
use aether_scheduler_core::{
|
||||||
build_scheduler_affinity_cache_key_for_api_key_id, SchedulerAffinityTarget,
|
build_scheduler_affinity_cache_key_for_api_key_id_with_client_session, ClientSessionAffinity,
|
||||||
|
SchedulerAffinityTarget,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::state::SchedulerRuntimeState;
|
use super::state::SchedulerRuntimeState;
|
||||||
@@ -11,13 +12,15 @@ pub(crate) const SCHEDULER_AFFINITY_TTL: Duration = Duration::from_secs(300);
|
|||||||
pub(crate) fn read_cached_scheduler_affinity_target(
|
pub(crate) fn read_cached_scheduler_affinity_target(
|
||||||
state: &(impl SchedulerRuntimeState + ?Sized),
|
state: &(impl SchedulerRuntimeState + ?Sized),
|
||||||
api_key_id: &str,
|
api_key_id: &str,
|
||||||
|
client_session_affinity: Option<&ClientSessionAffinity>,
|
||||||
api_format: &str,
|
api_format: &str,
|
||||||
global_model_name: &str,
|
global_model_name: &str,
|
||||||
) -> Option<SchedulerAffinityTarget> {
|
) -> Option<SchedulerAffinityTarget> {
|
||||||
let cache_key = build_scheduler_affinity_cache_key_for_api_key_id(
|
let cache_key = build_scheduler_affinity_cache_key_for_api_key_id_with_client_session(
|
||||||
api_key_id,
|
api_key_id,
|
||||||
api_format,
|
api_format,
|
||||||
global_model_name,
|
global_model_name,
|
||||||
|
client_session_affinity,
|
||||||
)?;
|
)?;
|
||||||
state.read_cached_scheduler_affinity_target(&cache_key, SCHEDULER_AFFINITY_TTL)
|
state.read_cached_scheduler_affinity_target(&cache_key, SCHEDULER_AFFINITY_TTL)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use aether_scheduler_core::{
|
use aether_scheduler_core::{
|
||||||
build_scheduler_affinity_cache_key_for_api_key_id, candidate_affinity_hash, candidate_key,
|
build_scheduler_affinity_cache_key_for_api_key_id_with_client_session, candidate_affinity_hash,
|
||||||
matches_affinity_target, SchedulerAffinityTarget,
|
candidate_key, matches_affinity_target, ClientSessionAffinity, SchedulerAffinityTarget,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::data::auth::GatewayAuthApiKeySnapshot;
|
use crate::data::auth::GatewayAuthApiKeySnapshot;
|
||||||
@@ -15,11 +15,17 @@ pub(super) fn build_scheduler_affinity_cache_key(
|
|||||||
auth_snapshot: Option<&GatewayAuthApiKeySnapshot>,
|
auth_snapshot: Option<&GatewayAuthApiKeySnapshot>,
|
||||||
api_format: &str,
|
api_format: &str,
|
||||||
global_model_name: &str,
|
global_model_name: &str,
|
||||||
|
client_session_affinity: Option<&ClientSessionAffinity>,
|
||||||
) -> Option<String> {
|
) -> Option<String> {
|
||||||
let api_key_id = auth_snapshot
|
let api_key_id = auth_snapshot
|
||||||
.map(|snapshot| snapshot.api_key_id.trim())
|
.map(|snapshot| snapshot.api_key_id.trim())
|
||||||
.filter(|value| !value.is_empty())?;
|
.filter(|value| !value.is_empty())?;
|
||||||
build_scheduler_affinity_cache_key_for_api_key_id(api_key_id, api_format, global_model_name)
|
build_scheduler_affinity_cache_key_for_api_key_id_with_client_session(
|
||||||
|
api_key_id,
|
||||||
|
api_format,
|
||||||
|
global_model_name,
|
||||||
|
client_session_affinity,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn scheduler_candidate_affinity_hash(
|
pub(super) fn scheduler_candidate_affinity_hash(
|
||||||
|
|||||||
Reference in New Issue
Block a user