Closed
Description
When a user registers:
- They click Register on the site
- The site
POSTs /resources {challengeId, memberId, roleId}
- Resource API writes to Dynamo, posts a bus message that a resource has been created
Two things happen at the same time:
- resource-processor-es picks up that message and writes the new resource to ES
- challenge-processor-es picks up that message and queries
GET /resources?challengeId&roleId
to get the count to updatenumOfRegistrants
on the challenge object.
The symptom of this is that the user is registered and shows up in the registration list fine, but the numOfRegistrants on the challenge object in es is only right about half the time.
I see two options:
- Create a lifecycle for an object, where an API will post a bus message in the present tense, and a processor will post a message in the past tense.
- For example: if you
POST /resource { challengeId, roleId, memberId }
the API will create that object in dynamo and post a bus messagechallenge.resource.action.create
. The ES processor will pick that up, do what it needs to, and post a bus messagechallenge.resource.action.created
. Then listeners can pick up on the appropriate timing.
- For example: if you
- Write directly to ES from the API and post the message as it does now. The resource-processor-es will only be for post-processing of bus messages where necessary.