I have a use case where I will show tabular data to user on UI where user can take action on each row (say each row will be having selection dropdown to select some column value). User can take action on multiple rows and submit on UI. As user submits , my backend service API will be invoked which will further invoke an external API (API 1) that will further process the selection values provided by user. Also the page will be enabled for certain duration only (say 'X' minutes) for user to take action.
Complete Flow currently looks like (Flow 1) : UI -> middle_layer -> backend_layer (update DDB with selected values) -> external API(API 1)
I also have state machine (AWS Step Function) workflow where a Step invokes a task to send email notifications to user to take action on UI . Email notification will contain UI link for the page mentioned above
Next step in State machine is to wait for 'X' mins and if no action is taken by user on UI , then with some default values for selection dropdown , it calls the same external API (API 1) for all the rows where user has not taken any action
Race condition arises with 2 actors performing similar operation when user takes action on UI just before time ends (Flow 1) and Step function also executes step to execute row with default selection.
Note : I will also update my backend dynamoDb table with the user selected values . Each row that we will show on UI has unique identifier stored in dynamoDb table. Thus , when step function invokes last step to execute rows (where action is not taken on UI) , it will scan ddb table to find which row is not updated and will call the external API (API 1) with default selection value.
I want :
- Backend API when user submits the selection for rows to update only dynamo db table and not invoke external API
New Flow : UI -> middle_layer -> backend_layer (update DDB with selected values)
- Step function to take responsibility of executing all the rows parallely (trigger based - if an action is taken with some selection value on UI or after 'X' minutes with default values) .
I read about map states of Step function where each row can have their map state and be invoked when some trigger is there (user takes an action) or else will be executed with default value after 'X' minutes .
Can somebody suggest design pattern/ approach for solving this ?
Aucun commentaire:
Enregistrer un commentaire