batch http requests

后端 未结 7 1906
[愿得一人]
[愿得一人] 2021-02-01 06:31

Does anyone know a standard way to batch http requests? Meaning - sending multiple http atomic requests in one round trip?

We need such mechanism in our REST API implem

7条回答
  •  鱼传尺愫
    2021-02-01 07:14

    You create batch requests by calling new_batch_http_request() on your service object, which returns a BatchHttpRequest object, and then calling add() for each request you want to execute. You may pass in a callback with each request that is called with the response to that request. The callback function arguments are a unique request identifier for each API call, a response object which contains the API call response, and an exception object which may be set to an exception raised by the API call. After you've added the requests, you call execute() to make the requests. The execute() function blocks until all callbacks have been called.

    References:

    You can try this too https://developers.google.com/api-client

    library/python/guide/batch

    https://cloud.google.com/storage/docs/json_api/v1/how-tos/batch

提交回复
热议问题