longrunning.yaml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. type: google.api.Service
  2. config_version: 3
  3. name: longrunning.googleapis.com
  4. title: Long Running Operations API
  5. apis:
  6. - name: google.longrunning.Operations
  7. types:
  8. - name: google.longrunning.OperationInfo
  9. documentation:
  10. overview: |-
  11. # Long Running Operation API
  12. This package contains the definition of Long Running Operation (LRO)
  13. interface. It is a standard interface that API services can implement for
  14. managing asynchronous operations.
  15. ## What are Long Running Operations?
  16. A Long Running Operation (LRO) is a way of representing an action that may
  17. take a significant amount of time to complete. For example, an API call
  18. that starts exporting a large amount of data could take quite a while to
  19. complete and is therefore best represented as an LRO. A common rule of
  20. thumb is to think of LROs as "API promises" that represent the result of
  21. some on-going action.
  22. For more information, see [AIP-151](https://google.aip.dev/151).
  23. ## Using LROs
  24. If an API method could potentially take long time to finish, the method
  25. should return a long running operation instead of a direct response. This
  26. means that even if there are situations where the response could be
  27. immediate, the API should still return an LRO -- it just may be already
  28. marked as completed.
  29. For example, if a data export operation is called on an empty resource,
  30. the operation itself may be possible to execute immediately, and would
  31. result in an already completed LRO.
  32. Additionally, the operation should be managed using the LRO interface,
  33. which allows clients to poll the operation for status updates or cancel it
  34. entirely.
  35. Finally, an LRO represents an action and as a result, the operation is not
  36. created directly. Instead, the operation comes into existence as a
  37. side-effect of the action it represents. For example, an RPC called
  38. `ExportData` would
  39. create and return an LRO. This means that there should never be an RPC
  40. called `CreateOperation`.
  41. This also means that any permissions on the operation would be based on
  42. the action it represents. Any immediate side effects of starting the
  43. operation must be visible in the service as soon as the LRO is returned.
  44. For example, if an LRO is returned when creating a resource, that resource
  45. should be visible in the API immediately, but be in a non-final state
  46. until the LRO is completed.
  47. ## LROs versus Jobs
  48. A [job](https://google.aip.dev/152) is a common design pattern often used
  49. in data processing that tends to be used to represent some contained piece
  50. of work that would be stored, re-run, and modified over time. Jobs also
  51. typically
  52. interact with multiple resources and are created, deleted, and updated
  53. directly as independent resources.
  54. Jobs can also offer support for more complex actions such as pausing and
  55. resuming an individual job, where each action could return an LRO as a
  56. response.
  57. In general, if an action may take a while but it represents a single piece
  58. of work, it's best to represent the response as an LRO. If the action is
  59. something more complex (for example, it involves lots of resources and
  60. can't be created as a byproduct of a single action), it may make more
  61. sense to represent it as a job.