Approach for REST request with long execution time?

前端 未结 4 1792
予麋鹿
予麋鹿 2020-12-13 16:36

We are building a REST service that will take about 5 minutes to execute. It will be only called a few times a day by an internal app. Is there an issue using a REST (ie:

4条回答
  •  北海茫月
    2020-12-13 17:41

    This is one approach.

    Create a new request to perform ProcessXYZ

    POST /ProcessXYZRequests
    
    201-Created
    Location: /ProcessXYZRequest/987
    

    If you want to see the current status of the request:

    GET /ProcessXYZRequest/987
    
    
      In progress
      
    
    

    when the request is finished you would see something like

    GET /ProcessXYZRequest/987
    
    
      Completed
      
    
    

    Using this approach you can easily imagine what the following requests would give

    GET  /ProcessXYZRequests/Pending
    GET  /ProcessXYZRequests/Completed
    GET  /ProcessXYZRequests/Failed
    GET  /ProcessXYZRequests/Today
    

提交回复
热议问题