Skip to content

Commit

Permalink
feat(s2n-quic-core): implement nominal timers
Browse files Browse the repository at this point in the history
  • Loading branch information
camshaft committed Nov 7, 2024
1 parent cfd87b9 commit d847e6d
Show file tree
Hide file tree
Showing 26 changed files with 1,839 additions and 891 deletions.
5 changes: 4 additions & 1 deletion dc/s2n-quic-dc/events/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@

struct ConnectionMeta {
id: u64,
timestamp: Timestamp,
}

struct EndpointMeta {}
struct EndpointMeta {
timestamp: Timestamp,
}

struct ConnectionInfo {}
3 changes: 3 additions & 0 deletions dc/s2n-quic-dc/events/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ struct PathSecretMapUninitialized {
/// The number of entries in the map
#[measure("entries")]
entries: usize,

#[measure("lifetime")]
lifetime: core::time::Duration,
}

#[event("path_secret_map:background_handshake_requested")]
Expand Down
2 changes: 1 addition & 1 deletion dc/s2n-quic-dc/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#[cfg(any(test, feature = "testing"))]
use s2n_quic_core::event::snapshot;

pub use s2n_quic_core::event::{Event, IntoEvent};
pub use s2n_quic_core::event::{Event, IntoEvent, Timestamp};

/// Provides metadata related to an event
pub trait Meta: core::fmt::Debug {
Expand Down
39 changes: 31 additions & 8 deletions dc/s2n-quic-dc/src/event/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,27 @@ pub mod api {
#[non_exhaustive]
pub struct ConnectionMeta {
pub id: u64,
pub timestamp: Timestamp,
}
#[cfg(any(test, feature = "testing"))]
impl crate::event::snapshot::Fmt for ConnectionMeta {
fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
let mut fmt = fmt.debug_struct("ConnectionMeta");
fmt.field("id", &self.id);
fmt.field("timestamp", &self.timestamp);
fmt.finish()
}
}
#[derive(Clone, Debug)]
#[non_exhaustive]
pub struct EndpointMeta {}
pub struct EndpointMeta {
pub timestamp: Timestamp,
}
#[cfg(any(test, feature = "testing"))]
impl crate::event::snapshot::Fmt for EndpointMeta {
fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
let mut fmt = fmt.debug_struct("EndpointMeta");
fmt.field("timestamp", &self.timestamp);
fmt.finish()
}
}
Expand Down Expand Up @@ -133,13 +138,15 @@ pub mod api {
pub capacity: usize,
#[doc = " The number of entries in the map"]
pub entries: usize,
pub lifetime: core::time::Duration,
}
#[cfg(any(test, feature = "testing"))]
impl crate::event::snapshot::Fmt for PathSecretMapUninitialized {
fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
let mut fmt = fmt.debug_struct("PathSecretMapUninitialized");
fmt.field("capacity", &self.capacity);
fmt.field("entries", &self.entries);
fmt.field("lifetime", &self.lifetime);
fmt.finish()
}
}
Expand Down Expand Up @@ -637,8 +644,12 @@ pub mod tracing {
event: &api::PathSecretMapUninitialized,
) {
let parent = self.parent(meta);
let api::PathSecretMapUninitialized { capacity, entries } = event;
tracing :: event ! (target : "path_secret_map_uninitialized" , parent : parent , tracing :: Level :: DEBUG , capacity = tracing :: field :: debug (capacity) , entries = tracing :: field :: debug (entries));
let api::PathSecretMapUninitialized {
capacity,
entries,
lifetime,
} = event;
tracing :: event ! (target : "path_secret_map_uninitialized" , parent : parent , tracing :: Level :: DEBUG , capacity = tracing :: field :: debug (capacity) , entries = tracing :: field :: debug (entries) , lifetime = tracing :: field :: debug (lifetime));
}
#[inline]
fn on_path_secret_map_background_handshake_requested(
Expand Down Expand Up @@ -921,23 +932,29 @@ pub mod builder {
#[derive(Clone, Debug)]
pub struct ConnectionMeta {
pub id: u64,
pub timestamp: Timestamp,
}
impl IntoEvent<api::ConnectionMeta> for ConnectionMeta {
#[inline]
fn into_event(self) -> api::ConnectionMeta {
let ConnectionMeta { id } = self;
let ConnectionMeta { id, timestamp } = self;
api::ConnectionMeta {
id: id.into_event(),
timestamp: timestamp.into_event(),
}
}
}
#[derive(Clone, Debug)]
pub struct EndpointMeta {}
pub struct EndpointMeta {
pub timestamp: Timestamp,
}
impl IntoEvent<api::EndpointMeta> for EndpointMeta {
#[inline]
fn into_event(self) -> api::EndpointMeta {
let EndpointMeta {} = self;
api::EndpointMeta {}
let EndpointMeta { timestamp } = self;
api::EndpointMeta {
timestamp: timestamp.into_event(),
}
}
}
#[derive(Clone, Debug)]
Expand Down Expand Up @@ -1030,14 +1047,20 @@ pub mod builder {
pub capacity: usize,
#[doc = " The number of entries in the map"]
pub entries: usize,
pub lifetime: core::time::Duration,
}
impl IntoEvent<api::PathSecretMapUninitialized> for PathSecretMapUninitialized {
#[inline]
fn into_event(self) -> api::PathSecretMapUninitialized {
let PathSecretMapUninitialized { capacity, entries } = self;
let PathSecretMapUninitialized {
capacity,
entries,
lifetime,
} = self;
api::PathSecretMapUninitialized {
capacity: capacity.into_event(),
entries: entries.into_event(),
lifetime: lifetime.into_event(),
}
}
}
Expand Down
Loading

0 comments on commit d847e6d

Please sign in to comment.