Skip to content

SSE support for EventService#28

Merged
yoks merged 15 commits intoNVIDIA:mainfrom
yoks:version-fix
Feb 20, 2026
Merged

SSE support for EventService#28
yoks merged 15 commits intoNVIDIA:mainfrom
yoks:version-fix

Conversation

@yoks
Copy link
Copy Markdown
Contributor

@yoks yoks commented Feb 18, 2026

No description provided.

Comment on lines +55 to +73
let value = JsonValue::deserialize(deserializer)?;
let odata_type = value
.get("@odata.type")
.and_then(JsonValue::as_str)
.ok_or_else(|| serde::de::Error::missing_field("missing @odata.type in SSE payload"))?;

if odata_type.starts_with("#MetricReport.") {
let payload =
serde_json::from_value::<MetricReport>(value).map_err(serde::de::Error::custom)?;
Ok(Self::MetricReport(payload))
} else if odata_type.starts_with("#Event.") {
let payload =
serde_json::from_value::<Event>(value).map_err(serde::de::Error::custom)?;
Ok(Self::Event(payload))
} else {
Err(serde::de::Error::custom(format!(
"unsupported @odata.type in SSE payload: {odata_type}, should be either #Event.* or #MetricReport.*"
)))
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread redfish/src/event_service/mod.rs Outdated
Comment on lines +107 to +113
/// `OData` identifier of the `EventService` in Redfish.
///
/// Typically `/redfish/v1/EventService`.
#[must_use]
pub fn odata_id(&self) -> &ODataId {
self.data.id()
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is redundant. Who needs odata_id() and why raw().id() wouldn't work for somebody who needs it in rare occasion?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like a pattern for our resources, we have it in other mdoules

Comment thread redfish/src/event_service/mod.rs Outdated
Comment on lines +134 to +140
let stream_id = ODataId::from(stream_uri.to_string());
self.bmc
.as_ref()
.stream::<EventStreamPayload>(&stream_id)
.await
.map_err(Error::Bmc)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This conversion from URI to ODataId looks very suspicious. I believe that if URI is provided it should stay URI. Is there any reasons why Bmc::stream should have ODataId as parameter?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

URI provided as String, but it in practice this is ODataId

Comment thread core/src/bmc.rs Outdated
/// `T` is structure that is used for the stream return type.
fn stream<T: Sized + for<'a> Deserialize<'a> + Send + 'static>(
&self,
id: &ODataId,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I commented this below but it looks like ODataId here is not the best choice. I would introduce another type like struct StreamPathRef<'a>(&String) and returned it from server_sent_event_uri function.

let mock_server = MockServer::start().await;
let sse_body = concat!(
"event: Alert\n",
"data: {\"event_id\":\"1\",\"severity\":\"Critical\"}\n\n",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Maybe better here: format!("data: {}", json!({event_id:"1","severity":"Critical"}))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sse has wierd requiremetns on how it is formated, so this is easier to control (newlines are important).

Comment thread redfish/src/event_service/mod.rs Outdated
Comment on lines +118 to +124
#[must_use]
pub fn server_sent_event_uri(&self) -> Result<&String, Error<B>> {
self.data
.server_sent_event_uri
.as_ref()
.ok_or(Error::EventServiceServerSentEventUriNotAvailable)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this function should stay private. We provide higher level interface for events access with events function.

@yoks yoks merged commit 84f2586 into NVIDIA:main Feb 20, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants