-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Overview
We need an API endpoint that returns the last event of a particular "type". See CLI ticket fore more context.
Route
GET /event-version/sample
Input Payload Example
{
"givenName": "allo.ProjectRegistry.ProjectCreated"
}Payload Validation
givenNamecan be validated using the same, copied-over,couldBeEventNamefunction added in the CLI (see ticket)
Successful Response - With Data
{
"event": {
"id": "...",
"name": "...",
"origin": {
...
},
"data": {
...
}
}
}Successful Response - No event data exists
This empty-but-successful response should be returned even if we don't have a matching event version stored in Core DB.
{
"event": null
}Strategy
Inside whatever service you end up writing to make this happen...
- Determine based on the structure of the
givenNamewhether the event is a Live Object event or a contract event.- An event name with only 2 "sections" (e.g.
station.MembershipUpserted) is distinctly a Live Object event. All contract events will have at least 3 sections.
- An event name with only 2 "sections" (e.g.
- Find some type of matching event version in Core DB for this
givenName:- Live Object events -- Should be simple lookup on
EventVersion - Contract events -- Use a combination of all possible chain-specific namespaces with the
givenNameas inputs to theresolveEventVersionNamesfunction to see if there's at least 1 event version associated with it.
- Live Object events -- Should be simple lookup on
- Return empty success if no match
- If an event version does exist for the
givenName, use that fully-resolved event "name" to look up the last published event of that particular type.- Should be able to break out
getLastEventIdinto 2 separate functions:getLastEventandgetLastEventId, the latter simply using the first after modifications. What this is doing is checking the redis stream for that particular event's last published instance, since we cache the last 500 of each event type.
- Should be able to break out
Metadata
Metadata
Assignees
Labels
No labels