mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-06 00:02:13 +00:00
* feat(EE): job debouncing Signed-off-by: pyranota <pyra@duck.com> * remove 'script' file Signed-off-by: pyranota <pyra@duck.com> * more work Signed-off-by: pyranota <pyra@duck.com> * properly gate it behind enterprise Signed-off-by: pyranota <pyra@duck.com> * update ee repo ref Signed-off-by: pyranota <pyra@duck.com> * change ee repo ref again Signed-off-by: pyranota <pyra@duck.com> * remove unused variable Signed-off-by: pyranota <pyra@duck.com> * feat(EE): implement TODOs and enhance tracing for job debouncing - Add database index on script(workspace_id, debounce_key) for efficient lookups - Update minimum version requirement to 1.564.0 throughout codebase - Add tracing warnings when debouncing is disabled due to worker version mismatch - Fix all documentation links from TODO placeholders to proper URLs - Replace Gauge icon with Timer icon for debouncing UI elements - Update placeholder text and tooltips with clear descriptions Co-authored-by: Pyra <pyranota@users.noreply.github.com> * create -> crate Signed-off-by: pyranota <pyra@duck.com> * remove index Signed-off-by: pyranota <pyra@duck.com> * some updates Signed-off-by: pyranota <pyra@duck.com> * fix once more Signed-off-by: pyranota <pyra@duck.com> * fix it once more Signed-off-by: pyranota <pyra@duck.com> * Remove flow step debouncing, keep top-level flow debouncing - Remove debounce fields from RawScript and FlowScript FlowModuleValue variants - Remove debounce fields from JobPayload::FlowScript and RawCode - Update raw_script_to_payload function signature - Remove debouncing UI from flow step runtime settings - Remove debouncing toggle handler and indicator badge - Preserve top-level flow debouncing in FlowSettings Co-authored-by: Pyra <pyranota@users.noreply.github.com> * cleanup Signed-off-by: pyranota <pyra@duck.com> * fixup claude's work Signed-off-by: pyranota <pyra@duck.com> * cleanup: remove dbg! statements, update min version to 1.566.0, add comprehensive comments - Removed all dbg! macro calls from production code - Updated MIN_VERSION_SUPPORTS_DEBOUNCING from 1.564.0 to 1.566.0 - Added comprehensive documentation comments explaining: - Debouncing feature purpose and mechanics - Database schema for debounce_key and debounce_stale_data tables - Version check logic and guard functions - Improved code clarity and maintainability Co-authored-by: Pyra <pyranota@users.noreply.github.com> * improve fallback Signed-off-by: pyranota <pyra@duck.com> * remove comments from old migration Signed-off-by: pyranota <pyra@duck.com> * fix pull Signed-off-by: pyranota <pyra@duck.com> * fix once more Signed-off-by: pyranota <pyra@duck.com> * Update frontend/src/lib/components/ScriptBuilder.svelte Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com> * add sqlx cache Signed-off-by: pyranota <pyra@duck.com> * fix: frontend CI - fix debounce field names and remove leftover flow step debouncing - Fix ScriptBuilder.svelte: change custom_debounce_key to debounce_key - Add debounce_key and debounce_delay_s fields to NewScript schema in openapi.yaml - Regenerate frontend types from OpenAPI spec - Remove leftover flow step debouncing code from FlowModuleComponent.svelte - Remove debounce fields from RawScript in openflow.openapi.yaml - Remove unused Timer import from FlowModuleHeader.svelte All frontend checks now passing (0 errors, 0 warnings) Co-authored-by: Pyra <pyranota@users.noreply.github.com> * fix ci Signed-off-by: pyranota <pyra@duck.com> * remove unused import Signed-off-by: pyranota <pyra@duck.com> * fix ci again Signed-off-by: pyranota <pyra@duck.com> * udpate ee repo ref Signed-off-by: pyranota <pyra@duck.com> * CI doesn't want to be fixed but I still try Signed-off-by: pyranota <pyra@duck.com> * nits Signed-off-by: pyranota <pyra@duck.com> * ci... Signed-off-by: pyranota <pyra@duck.com> * Update ee-repo-ref.txt * safer migration Signed-off-by: pyranota <pyra@duck.com> * reduce noise in logs Signed-off-by: pyranota <pyra@duck.com> * fix cli for scripts Signed-off-by: pyranota <pyra@duck.com> * nit Signed-off-by: pyranota <pyra@duck.com> --------- Signed-off-by: pyranota <pyra@duck.com> Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: Pyra <pyranota@users.noreply.github.com> Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com> Co-authored-by: windmill-internal-app[bot] <windmill-internal-app[bot]@users.noreply.github.com>
97 lines
2.9 KiB
Rust
97 lines
2.9 KiB
Rust
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Deserialize, Serialize)]
|
|
pub struct QueueInitJob {
|
|
pub content: String,
|
|
}
|
|
|
|
use lazy_static::lazy_static;
|
|
use std::time::Duration;
|
|
|
|
use reqwest_middleware::ClientBuilder;
|
|
use reqwest_retry::{policies::ExponentialBackoff, RetryTransientMiddleware};
|
|
|
|
use crate::{jwt::decode_without_verify, utils::configure_client, worker::HttpClient};
|
|
|
|
lazy_static! {
|
|
pub static ref AGENT_TOKEN: String = std::env::var("AGENT_TOKEN").unwrap_or_default();
|
|
pub static ref DECODED_AGENT_TOKEN: Option<AgentAuth> = {
|
|
if AGENT_TOKEN.is_empty() {
|
|
None
|
|
} else {
|
|
decode_without_verify::<AgentAuth>(AGENT_TOKEN.trim_start_matches(AGENT_JWT_PREFIX))
|
|
.ok()
|
|
}
|
|
};
|
|
}
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
pub struct AgentAuth {
|
|
pub worker_group: String,
|
|
pub suffix: Option<String>,
|
|
pub tags: Vec<String>,
|
|
pub exp: Option<usize>,
|
|
}
|
|
|
|
pub const AGENT_JWT_PREFIX: &str = "jwt_agent_";
|
|
|
|
pub fn build_agent_http_client(
|
|
worker_suffix: &str,
|
|
agent_token: Option<String>,
|
|
base_internal_url: Option<String>,
|
|
) -> HttpClient {
|
|
let client = ClientBuilder::new(
|
|
configure_client(reqwest::Client::builder()
|
|
.pool_max_idle_per_host(10)
|
|
.pool_idle_timeout(Duration::from_secs(60))
|
|
.connect_timeout(Duration::from_secs(10))
|
|
.timeout(Duration::from_secs(30)))
|
|
.default_headers({
|
|
let mut headers = reqwest::header::HeaderMap::new();
|
|
headers.insert(
|
|
"User-Agent", // Replace with your desired header name
|
|
"Windmill-Agent/1.0".parse().unwrap(), // Replace with your desired header value
|
|
);
|
|
let token = format!(
|
|
"{}{}_{}",
|
|
AGENT_JWT_PREFIX,
|
|
worker_suffix,
|
|
agent_token
|
|
.unwrap_or(AGENT_TOKEN.clone())
|
|
.trim_start_matches(AGENT_JWT_PREFIX)
|
|
);
|
|
headers.insert(
|
|
"Authorization",
|
|
format!("Bearer {}", token).parse().unwrap(),
|
|
);
|
|
headers
|
|
})
|
|
.build()
|
|
.expect("Failed to create HTTP client"),
|
|
)
|
|
.with(RetryTransientMiddleware::new_with_policy(
|
|
ExponentialBackoff::builder().build_with_max_retries(5),
|
|
))
|
|
.build();
|
|
|
|
HttpClient { client, base_internal_url }
|
|
}
|
|
|
|
#[derive(Deserialize, Serialize)]
|
|
pub struct PingJobStatus {
|
|
pub mem_peak: Option<i32>,
|
|
pub current_mem: Option<i32>,
|
|
}
|
|
|
|
#[derive(Deserialize, Serialize, Debug)]
|
|
pub struct PingJobStatusResponse {
|
|
pub canceled_by: Option<String>,
|
|
pub canceled_reason: Option<String>,
|
|
pub already_completed: bool,
|
|
}
|
|
|
|
// #[derive(Serialize, Deserialize)]
|
|
// pub struct PullJobRequest {
|
|
// pub worker_name: String,
|
|
// }
|