async.stone 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. namespace async
  2. #
  3. # Types for writing asynchronous API methods.
  4. #
  5. # There are two calls for each asynchronous method:
  6. # 1. A "Launch" method that (optionally) launches the asynchronous job
  7. # 2. A "Polling" method that polls for the status of the job that was launched by the first call.
  8. #
  9. # The following definitions are prefixed by "Launch" or "Poll", according to their intended use.
  10. alias AsyncJobId = String(min_length=1)
  11. #
  12. # Launch
  13. #
  14. union_closed LaunchResultBase
  15. "Result returned by methods that launch an asynchronous job.
  16. A method who may either launch an asynchronous job, or complete the request
  17. synchronously, can use this union by extending it, and adding a 'complete' field
  18. with the type of the synchronous response.
  19. See :type:`LaunchEmptyResult` for an example."
  20. async_job_id AsyncJobId
  21. "This response indicates that the processing is asynchronous.
  22. The string is an id that can be used to obtain the status of the asynchronous job."
  23. union_closed LaunchEmptyResult extends LaunchResultBase
  24. "Result returned by methods that may either launch an asynchronous job or complete synchronously.
  25. Upon synchronous completion of the job, no additional information is returned."
  26. complete
  27. "The job finished synchronously and successfully."
  28. example complete
  29. complete = null
  30. example async_job_id
  31. async_job_id = "34g93hh34h04y384084"
  32. #
  33. # Poll
  34. #
  35. struct PollArg
  36. "Arguments for methods that poll the status of an asynchronous job."
  37. async_job_id AsyncJobId
  38. "Id of the asynchronous job.
  39. This is the value of a response returned from the method that launched the job."
  40. example default
  41. async_job_id = "34g93hh34h04y384084"
  42. # TODO(kelkabany): Remove `error_msg` since others might want to return it
  43. # differently.
  44. union_closed PollResultBase
  45. "Result returned by methods that poll for the status of an asynchronous job.
  46. Unions that extend this union should add a 'complete' field with a type of
  47. the information returned upon job completion.
  48. See :type:`PollEmptyResult` for an example."
  49. in_progress
  50. "The asynchronous job is still in progress."
  51. union_closed PollEmptyResult extends PollResultBase
  52. "Result returned by methods that poll for the status of an asynchronous job.
  53. Upon completion of the job, no additional information is returned."
  54. complete
  55. "The asynchronous job has completed successfully."
  56. example complete
  57. complete = null
  58. example in_progress
  59. in_progress = null
  60. union PollError
  61. "Error returned by methods for polling the status of asynchronous job."
  62. invalid_async_job_id
  63. "The job ID is invalid."
  64. internal_error
  65. "Something went wrong with the job on Dropbox's end. You'll need to
  66. verify that the action you were taking succeeded, and if not, try
  67. again. This should happen very rarely."