Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Modularius committed Aug 30, 2024
1 parent 2782b74 commit 8166694
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 44 deletions.
14 changes: 3 additions & 11 deletions digitiser-aggregator/src/frame/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ where
match self
.frames
.iter_mut()
.find(|frame| frame.metadata.equals_ignoring_veto_flags(&metadata))
.find(|frame| frame.metadata.equals_ignoring_veto_flags(metadata))
{
Some(frame) => {
frame.push(digitiser_id, data);
Expand Down Expand Up @@ -109,11 +109,7 @@ mod test {

assert!(cache.poll().is_none());

cache.push(
8,
&frame_1,
EventData::dummy_data(0, 5, &[9, 10, 11]),
);
cache.push(8, &frame_1, EventData::dummy_data(0, 5, &[9, 10, 11]));

{
let frame = cache.poll().unwrap();
Expand Down Expand Up @@ -168,11 +164,7 @@ mod test {

assert!(cache.poll().is_none());

cache.push(
8,
&frame_1,
EventData::dummy_data(0, 5, &[9, 10, 11]),
);
cache.push(8, &frame_1, EventData::dummy_data(0, 5, &[9, 10, 11]));

assert!(cache.poll().is_none());

Expand Down
63 changes: 30 additions & 33 deletions digitiser-aggregator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ use supermusr_streaming_types::{
dev2_digitizer_event_v2_generated::{
digitizer_event_list_message_buffer_has_identifier, root_as_digitizer_event_list_message,
},
FrameMetadata,
};
use tokio::task::JoinSet;
use tracing::{debug, error, info_span, level_filters::LevelFilter, warn};
Expand Down Expand Up @@ -176,44 +175,42 @@ async fn on_message(
&[messages_received::get_label(MessageKind::Event)]
);
match root_as_digitizer_event_list_message(payload) {
Ok(msg) => {
match msg.metadata().try_into() {
Ok(metadata) => {
debug!("Event packet: metadata: {:?}", msg.metadata());
cache.push(msg.digitizer_id(), &metadata, msg.into());
Ok(msg) => match msg.metadata().try_into() {
Ok(metadata) => {
debug!("Event packet: metadata: {:?}", msg.metadata());
cache.push(msg.digitizer_id(), &metadata, msg.into());

if let Some(frame_span) = cache.find_span_mut(metadata) {
if frame_span.span().is_waiting() {
if let Err(e) = frame_span.span_init() {
error!("Tracing error: {e}");
}
}

if let Err(e) = frame_span.link_current_span(
|| info_span!(target: "otel", "Digitiser Event List"),
) {
if let Some(frame_span) = cache.find_span_mut(metadata) {
if frame_span.span().is_waiting() {
if let Err(e) = frame_span.span_init() {
error!("Tracing error: {e}");
}
}
cache_poll(
use_otel,
kafka_producer_thread_set,
cache,
producer,
output_topic,
)
.await;
}
Err(e) => {
warn!("Invalid Metadata: {e}");
counter!(
FAILURES,
&[failures::get_label(FailureKind::InvalidMetadata)]
)
.increment(1);

if let Err(e) = frame_span.link_current_span(
|| info_span!(target: "otel", "Digitiser Event List"),
) {
error!("Tracing error: {e}");
}
}
cache_poll(
use_otel,
kafka_producer_thread_set,
cache,
producer,
output_topic,
)
.await;
}
}
Err(e) => {
warn!("Invalid Metadata: {e}");
counter!(
FAILURES,
&[failures::get_label(FailureKind::InvalidMetadata)]
)
.increment(1);
}
},
Err(e) => {
warn!("Failed to parse message: {}", e);
counter!(
Expand Down

0 comments on commit 8166694

Please sign in to comment.