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
givenName can be validated using the same, copied-over, couldBeEventName function 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.
Strategy
Inside whatever service you end up writing to make this happen...
- Determine based on the structure of the
givenName whether 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.
- 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
givenName as inputs to the resolveEventVersionNames function to see if there's at least 1 event version associated with it.
- 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
getLastEventId into 2 separate functions: getLastEvent and getLastEventId, 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.
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/sampleInput 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
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.
Strategy
Inside whatever service you end up writing to make this happen...
givenNamewhether the event is a Live Object event or a contract event.station.MembershipUpserted) is distinctly a Live Object event. All contract events will have at least 3 sections.givenName:EventVersiongivenNameas inputs to theresolveEventVersionNamesfunction to see if there's at least 1 event version associated with it.givenName, use that fully-resolved event "name" to look up the last published event of that particular type.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.