Skip to content

Commit 6c7057f

Browse files
authored
feat(s2n-quic-platform): emit socket events (#2356)
1 parent 192de7d commit 6c7057f

File tree

29 files changed

+1157
-267
lines changed

29 files changed

+1157
-267
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ Cargo.lock
1212
dhat-heap.json
1313
flamegraph.svg
1414
perf.data*
15+
*.snap.new

dc/s2n-quic-dc/src/event/generated.rs

+49
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,55 @@ pub mod testing {
439439
use crate::event::snapshot::Location;
440440
use core::sync::atomic::{AtomicU32, Ordering};
441441
use std::sync::Mutex;
442+
pub mod endpoint {
443+
use super::*;
444+
pub struct Subscriber {
445+
location: Option<Location>,
446+
output: Mutex<Vec<String>>,
447+
}
448+
impl Drop for Subscriber {
449+
fn drop(&mut self) {
450+
if std::thread::panicking() {
451+
return;
452+
}
453+
if let Some(location) = self.location.as_ref() {
454+
location.snapshot_log(&self.output.lock().unwrap());
455+
}
456+
}
457+
}
458+
impl Subscriber {
459+
#[doc = r" Creates a subscriber with snapshot assertions enabled"]
460+
#[track_caller]
461+
pub fn snapshot() -> Self {
462+
let mut sub = Self::no_snapshot();
463+
sub.location = Location::from_thread_name();
464+
sub
465+
}
466+
#[doc = r" Creates a subscriber with snapshot assertions enabled"]
467+
#[track_caller]
468+
pub fn named_snapshot<Name: core::fmt::Display>(name: Name) -> Self {
469+
let mut sub = Self::no_snapshot();
470+
sub.location = Some(Location::new(name));
471+
sub
472+
}
473+
#[doc = r" Creates a subscriber with snapshot assertions disabled"]
474+
pub fn no_snapshot() -> Self {
475+
Self {
476+
location: None,
477+
output: Default::default(),
478+
}
479+
}
480+
}
481+
impl super::super::Subscriber for Subscriber {
482+
type ConnectionContext = ();
483+
fn create_connection_context(
484+
&self,
485+
_meta: &api::ConnectionMeta,
486+
_info: &api::ConnectionInfo,
487+
) -> Self::ConnectionContext {
488+
}
489+
}
490+
}
442491
#[derive(Clone, Debug)]
443492
pub struct Subscriber {
444493
location: Option<Location>,

0 commit comments

Comments
 (0)