cache: wire rest get response caching
This commit is contained in:
@@ -66,7 +66,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let cache_stores = RuntimeCacheStores::from_config(&cache_config).await?;
|
||||
let api_rate_limit = admin_api_rate_limit_config_from_env()?;
|
||||
let secret_crypto = SecretCrypto::new(&env::var("CRANK_MASTER_KEY")?)?;
|
||||
let runtime = RuntimeExecutor::with_limits(runtime_limits);
|
||||
let runtime = RuntimeExecutor::with_limits(runtime_limits)
|
||||
.with_response_cache_store(cache_stores.response.clone());
|
||||
let service = AdminService::new_with_runtime(
|
||||
registry,
|
||||
storage_root,
|
||||
|
||||
@@ -702,7 +702,11 @@ async fn handle_base_tool_call(
|
||||
transport_request_id: &str,
|
||||
) -> Response {
|
||||
let operation = runtime_operation(&tool);
|
||||
let runtime_request_context = RuntimeRequestContext::from_request_id(transport_request_id);
|
||||
let runtime_request_context = RuntimeRequestContext::from_request_id(transport_request_id)
|
||||
.with_response_cache_scope(
|
||||
tool.workspace_id.as_str().to_owned(),
|
||||
tool.agent_id.as_str().to_owned(),
|
||||
);
|
||||
let request_preview = build_request_preview(&state.runtime, &operation, &arguments);
|
||||
let started_at = Instant::now();
|
||||
let is_window_mode = matches!(
|
||||
@@ -813,7 +817,11 @@ async fn handle_session_start_call(
|
||||
transport_request_id: &str,
|
||||
) -> Response {
|
||||
let runtime_operation = runtime_operation(&tool);
|
||||
let runtime_request_context = RuntimeRequestContext::from_request_id(transport_request_id);
|
||||
let runtime_request_context = RuntimeRequestContext::from_request_id(transport_request_id)
|
||||
.with_response_cache_scope(
|
||||
tool.workspace_id.as_str().to_owned(),
|
||||
tool.agent_id.as_str().to_owned(),
|
||||
);
|
||||
let request_preview = build_request_preview(&state.runtime, &runtime_operation, &arguments);
|
||||
let started_at = Instant::now();
|
||||
let Some(streaming) = runtime_operation.execution_config.streaming.as_ref() else {
|
||||
@@ -1240,7 +1248,11 @@ async fn handle_async_job_start_call(
|
||||
transport_request_id: &str,
|
||||
) -> Response {
|
||||
let operation = runtime_operation(&tool);
|
||||
let runtime_request_context = RuntimeRequestContext::from_request_id(transport_request_id);
|
||||
let runtime_request_context = RuntimeRequestContext::from_request_id(transport_request_id)
|
||||
.with_response_cache_scope(
|
||||
tool.workspace_id.as_str().to_owned(),
|
||||
tool.agent_id.as_str().to_owned(),
|
||||
);
|
||||
let request_preview = build_request_preview(&state.runtime, &operation, &arguments);
|
||||
let Some(streaming) = tool.operation.execution_config.streaming.as_ref() else {
|
||||
return tool_error_response(
|
||||
|
||||
@@ -54,7 +54,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
)
|
||||
.await?;
|
||||
let secret_crypto = SecretCrypto::new(&env::var("CRANK_MASTER_KEY")?)?;
|
||||
let runtime = RuntimeExecutor::with_limits(runtime_limits);
|
||||
let runtime = RuntimeExecutor::with_limits(runtime_limits)
|
||||
.with_response_cache_store(cache_stores.response.clone());
|
||||
let app = build_app(
|
||||
registry,
|
||||
refresh_interval,
|
||||
@@ -3043,6 +3044,7 @@ mod tests {
|
||||
execution_config: ExecutionConfig {
|
||||
timeout_ms: 1_000,
|
||||
retry_policy: None,
|
||||
response_cache: None,
|
||||
auth_profile_ref: None,
|
||||
headers: BTreeMap::new(),
|
||||
protocol_options: None,
|
||||
@@ -3109,6 +3111,7 @@ mod tests {
|
||||
execution_config: ExecutionConfig {
|
||||
timeout_ms: 1_000,
|
||||
retry_policy: None,
|
||||
response_cache: None,
|
||||
auth_profile_ref: None,
|
||||
headers: BTreeMap::new(),
|
||||
protocol_options: None,
|
||||
@@ -3176,6 +3179,7 @@ mod tests {
|
||||
execution_config: ExecutionConfig {
|
||||
timeout_ms: 1_000,
|
||||
retry_policy: None,
|
||||
response_cache: None,
|
||||
auth_profile_ref: None,
|
||||
headers: BTreeMap::new(),
|
||||
protocol_options: None,
|
||||
|
||||
Reference in New Issue
Block a user