MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / prune

Function prune

mserver/MasterService/src/probe.rs:79–94  ·  view source on GitHub ↗
(config: &ProbeConfig, max_age: Duration)

Source from the content-addressed store, hash-verified

77}
78
79fn prune(config: &ProbeConfig, max_age: Duration) -> Result<usize> {
80 let url = format!("{}/v1/servers/prune", base_url(config));
81 let payload = PruneServersRequest {
82 max_age_ms: i64::try_from(max_age.as_millis()).unwrap_or(i64::MAX),
83 };
84 let request = match &config.admin_api_key {
85 Some(key) => ureq::post(&url).set("x-api-key", key),
86 None => ureq::post(&url),
87 };
88 let response: PruneServersResponse = request
89 .send_json(&payload)
90 .context("pruning stale servers")?
91 .into_json()
92 .context("parsing prune response")?;
93 Ok(response.removed)
94}
95
96fn base_url(config: &ProbeConfig) -> &str {
97 config.master_server.trim_end_matches('/')

Callers 1

runFunction · 0.85

Calls 1

setMethod · 0.45

Tested by

no test coverage detected