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

Function log_event_for_device

chirpstack/src/stream/event.rs:17–58  ·  view source on GitHub ↗
(typ: &str, dev_eui: &str, b: &[u8])

Source from the content-addressed store, hash-verified

15
16#[allow(clippy::enum_variant_names)]
17pub async fn log_event_for_device(typ: &str, dev_eui: &str, b: &[u8]) -> Result<()> {
18 let conf = config::get();
19
20 // per device stream
21 if conf.monitoring.per_device_event_log_max_history > 0 {
22 let key = redis_key(format!("device:{{{}}}:stream:event", dev_eui));
23 () = redis::pipe()
24 .atomic()
25 .cmd("XADD")
26 .arg(&key)
27 .arg("MAXLEN")
28 .arg("~")
29 .arg(conf.monitoring.per_device_event_log_max_history)
30 .arg("*")
31 .arg(typ)
32 .arg(b)
33 .ignore()
34 .cmd("PEXPIRE")
35 .arg(&key)
36 .arg(conf.monitoring.per_device_event_log_ttl.as_millis() as usize)
37 .ignore()
38 .query_async(&mut get_async_redis_conn().await?)
39 .await?;
40 }
41
42 // global device stream
43 if conf.monitoring.device_event_log_max_history > 0 {
44 let key = redis_key("device:stream:event".to_string());
45 () = redis::cmd("XADD")
46 .arg(&key)
47 .arg("MAXLEN")
48 .arg("~")
49 .arg(conf.monitoring.device_event_log_max_history)
50 .arg("*")
51 .arg(typ)
52 .arg(b)
53 .query_async(&mut get_async_redis_conn().await?)
54 .await?;
55 }
56
57 Ok(())
58}
59
60pub async fn get_event_logs(
61 key: String,

Callers 7

uplink_eventMethod · 0.85
join_eventMethod · 0.85
ack_eventMethod · 0.85
txack_eventMethod · 0.85
log_eventMethod · 0.85
status_eventMethod · 0.85
location_eventMethod · 0.85

Calls 4

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

Tested by

no test coverage detected