Deduplicate event ids
Redfish specification states:
```
The value of the id field shall be the same as the Id property in the
event payload. The value of the Id property in the event payload should
be the same as the EventId property of the last event record in the
Events array. The value of the EventId property for an event record
should be a positive integer value and should be generated in a
sequential manner.
```
The event service code did not implement that correctly. So:
1. Add ID fields for all events.
2. Remove the per-sse connection id field and rely solely on
EventServiceManager.
3. Make sure all paths, (including metric report) are generating an
event id that's based on the eventservice event id
Tested: Redfish event listener now sees events populated.
LastEventId when sent to the SSE socket now sees a contiguous id.
```
uri=$(curl -s --user "root:0penBmc" -k "https://192.168.7.2/redfish/v1/EventService" | jq -r .ServerSentEventUri)
curl -u root:0penBmc -vvv -k -N -H "Accept: text/event-stream" -H "Last-Event-Id: 0" "https://192.168.7.2$uri"
```
Change-Id: Ic32e036f40a53a9b2715639ae384d7891c768260
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/redfish-core/lib/event_service.hpp b/redfish-core/lib/event_service.hpp
index ea968af..fa003e3 100644
--- a/redfish-core/lib/event_service.hpp
+++ b/redfish-core/lib/event_service.hpp
@@ -197,12 +197,17 @@
return;
}
+ // From the Redfish spec on EventId
+ // A service can ignore this value and replace it with its own.
+ // note that this parameter is intentionally ignored
+
+ std::optional<std::string> eventId;
TestEvent testEvent;
// clang-format off
if (!json_util::readJsonAction(
req, asyncResp->res,
"EventGroupId", testEvent.eventGroupId,
- "EventId", testEvent.eventId,
+ "EventId", eventId,
"EventTimestamp", testEvent.eventTimestamp,
"Message", testEvent.message,
"MessageArgs", testEvent.messageArgs,