MCPcopy Create free account
hub / github.com/chirpstack/chirpstack / log_request

Function log_request

chirpstack/src/stream/api_request.rs:8–29  ·  view source on GitHub ↗
(pl: &stream::ApiRequestLog)

Source from the content-addressed store, hash-verified

6use chirpstack_api::stream;
7
8pub async fn log_request(pl: &stream::ApiRequestLog) -> Result<()> {
9 let conf = config::get();
10
11 if conf.monitoring.api_request_log_max_history == 0 {
12 return Ok(());
13 }
14
15 let key = redis_key("api:stream:request".to_string());
16 let b = pl.encode_to_vec();
17 () = redis::cmd("XADD")
18 .arg(&key)
19 .arg("MAXLEN")
20 .arg("~")
21 .arg(conf.monitoring.api_request_log_max_history)
22 .arg("*")
23 .arg("request")
24 .arg(&b)
25 .query_async(&mut get_async_redis_conn().await?)
26 .await?;
27
28 Ok(())
29}
30
31#[cfg(test)]
32mod tests {

Callers 3

test_log_requestFunction · 0.70
pollMethod · 0.50
log_request_responseFunction · 0.50

Calls 4

redis_keyFunction · 0.85
get_async_redis_connFunction · 0.85
to_stringMethod · 0.80
getFunction · 0.50

Tested by 1

test_log_requestFunction · 0.56