MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / is_timeseries_cdc_enabled

Function is_timeseries_cdc_enabled

nodedb/src/control/server/dispatch_utils.rs:369–385  ·  view source on GitHub ↗

Check if a timeseries collection has CDC enabled. Returns `false` (CDC off) by default for timeseries to prevent high-cardinality metric streams from flooding the ChangeStream bus. Users opt in via `CREATE TIMESERIES name WITH (cdc = 'true')`.

(shared: &SharedState, tenant_id: TenantId, collection: &str)

Source from the content-addressed store, hash-verified

367/// high-cardinality metric streams from flooding the ChangeStream bus.
368/// Users opt in via `CREATE TIMESERIES name WITH (cdc = 'true')`.
369fn is_timeseries_cdc_enabled(shared: &SharedState, tenant_id: TenantId, collection: &str) -> bool {
370 if let Some(catalog) = shared.credentials.catalog()
371 && let Ok(Some(coll)) =
372 catalog.get_collection(DatabaseId::DEFAULT, tenant_id.as_u64(), collection)
373 && coll.collection_type.is_timeseries()
374 {
375 if let Some(config) = coll.get_timeseries_config()
376 && let Some(cdc_val) = config.get("cdc")
377 {
378 return cdc_val.as_str() == Some("true") || cdc_val.as_bool() == Some(true);
379 }
380 // Default: CDC off for timeseries.
381 return false;
382 }
383 // Not timeseries or catalog unavailable — allow publishing.
384 true
385}
386
387#[cfg(test)]
388mod collect_budget_tests {

Callers 1

Calls 8

get_timeseries_configMethod · 0.80
catalogMethod · 0.45
get_collectionMethod · 0.45
as_u64Method · 0.45
is_timeseriesMethod · 0.45
getMethod · 0.45
as_strMethod · 0.45
as_boolMethod · 0.45

Tested by

no test coverage detected