Background processing



Sometimes we have long API operations that takes minutes or even hours to be done. In that case CloudFlare returns error 503 (Service unavailable) to the client. Which is not quite true because itユs just long but normal operation.


We have 2 options to fix those problems: background processing and asynchronous processing. In case of asynchronous processing the request sent to the queue for further processing. This is not implemented yet.

Background processing means API continue processing of this request but respond instantly with request id and user can periodically check status of this request.


Any API request can be converted to background one by addings bgrs parameter equal to ヤyesユ or 1. In that case API instantly respond with background request id but continue processing of current request. E.g. for request, we get:

{"request": "4ff7cc2d88b1de88e83cce3f1caa1509"}

To get general information about background request following call to be used:

  "id": "267",
  "rid": "4ff7cc2d88b1de88e83cce3f1caa1509",
  "user_id": "1",
  "name": "/v2.5/users/me?bgrs=yes",
  "created_dt": "2017-12-26 18:21:52",
  "status_id": "4",
  "status_name": "finished",
  "progress": "100.00",
  "finished_dt": "2017-12-26 18:21:52",
  "status": "200",
  "content_type": "application/json; charset=utf-8",
  "result": "media/keep1m.bgrs.4ff7cc2d88b1de88e83cce3f1caa1509.result.json"

To get details of the request (it can be a lot of records for long API calls; itユs not the case for our example call, though) following call to be used:

  "id": "5802",
  "rid": "4ff7cc2d88b1de88e83cce3f1caa1509",
  "dt": "2017-12-26 18:21:52",
  "details": "done"

Result of the background call can be taken using this call: Actual result depends on the original call - so in our case it will be json. For call like it will be csv file:

API doesnユt check rights to data provided by bgrs/BGR_ID/result. Caller only should provide ANY valid BEAR API credentials. That means you can share results taken by you with any BEAR user.

Cet article vous a-t-il été utile ?
Utilisateurs qui ont trouvé cela utile : 0 sur 0


0 commentaire

Vous devez vous connecter pour laisser un commentaire.