Return-sync infrastructure.
What is the purpose of this article?
This article shows the graphical representation of infrastructure that are participants in Returns-sync to Algolia.
Components of Return-sync
Below are the details of the components that take part in the Return-sync in a production environment.
Component | Name | Value | URL |
---|---|---|---|
Google Could Platform | Project | eshopbox_client_portal_prod |
|
Google Could Platform | App-Engine Service | backend |
|
Google Could Platform | Cloud Scheduler | returnsUpdateCron | https://backend-dot-eshopbox-client-portal-prod.appspot.com/_ah/api/esb/v1/returnsCron |
Google Could Platform | Taskqueue/ Cloud Task | returnSync | https://backend-dot-eshopbox-client-portal-prod.appspot.com/_ah/api/esb/v1/returnUpdatedTaskQueue |
Google Could Platform | Taskqueue/ Cloud Task | returnSyncProcessing | https://backend-dot-eshopbox-client-portal-prod.appspot.com/_ah/api/esb/v1/returnUpdateProcessingQueue |
Database | eshopbox_wms_production |
|
|
API | OrderReturnEndpoint | returnsCron |
|
API | OrderReturnEndpoint | returnUpdatedTaskQueue |
|
API | OrderReturnEndpoint | returnUpdateProcessingQueue |
|
Gitlab Repository | Inventory Engine - Client Portal | Inventory Engine - Client Portal | https://gitlab.com/eshopbox-team/inventory-engine |
Algolia | OrderReturnsProd | es_prod | https://www.algolia.com/apps/W7AL34LYP4/explorer/browse/es_prod?searchMode=search |
Search API (used by FE and other projects) | OrderReturnEnpoint | searchOrderReturnIndexData |
|
Infrastructure Diagram.
Steps/ Sequence followed by Return-sync.
Every 15 minutes, Google cloud scheduler schedules a job for returnUpdateCron in cloud Scheduler.
Scheduled job then targets the API: /_ah/api/esb/v1/returnsCron ( returnsCron f(n) ) in OrderReturnEndpoint.
returnsCron function in OrderReturnEndpoint queries for the 1st record based on created_at column in descending order from eshopbox_wms_production.order_return_algolia_sync table of job_type: “RETURN_JOB“.
The database returns one record as per the selection query. Based on the records from the query, check if ‘status' is either ‘1' or ‘2’. If true, then return nothing as status 1 and 2 means that the previous return-sync is still running and is yet to finish its cycle. If the status is '0’, then set status as '1’ and then update the record in the database.
Enclose the updated record object in json format and send the request to “returnSync” taskqueue in Cloud Task.
“returnSync“ taskqueue targets the API: /_ah/api/esb/v1/returnUpdatedTaskQueue ( returnUpdatedTaskQueue f(n) ) in OrderReturnEndpoint.
In API returnUpdatedTaskQueue f(n), deduct 30 min from the end date send in the request. This becomes the start date for the current return sync. The current date-time becomes our end date for the present return sync.