MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / tail_nf

Function tail_nf

crates/core/src/database_logger.rs:787–802  ·  view source on GitHub ↗

Test calling [DatabaseLogger::tail] with both `Some(n)` and `follow = true`. Like `tail -n N -f`.

(logger: DatabaseLogger)

Source from the content-addressed store, hash-verified

785 ///
786 /// Like `tail -n N -f`.
787 async fn tail_nf(logger: DatabaseLogger) {
788 let logger = Arc::new(logger);
789
790 write_logs(logger.clone(), 0..10).await;
791 let stream = logger.tail(Some(5), true).await.unwrap().try_collect::<BytesMut>();
792 write_logs(logger.clone(), 10..20).await;
793 // Drop logger so stream terminates.
794 drop_logger(logger);
795
796 let raw_logs = stream.await.unwrap();
797 let json_logs = deserialize_logs(&raw_logs).unwrap();
798
799 assert_eq!(json_logs.len(), 15);
800 assert_eq!(json_logs[0].message, "log line 5");
801 assert_eq!(json_logs[14].message, "log line 19");
802 }
803
804 mod memory {
805 use super::DatabaseLogger;

Callers

nothing calls this directly

Calls 8

write_logsFunction · 0.85
drop_loggerFunction · 0.85
deserialize_logsFunction · 0.85
with_file_loggerFunction · 0.85
tailMethod · 0.80
newFunction · 0.50
cloneMethod · 0.45
unwrapMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…