Timeline for How to design a REST API that can "prompt" the client about long-running operations?
Current License: CC BY-SA 4.0
17 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Aug 26, 2020 at 2:29 | audit | First posts | |||
| Aug 26, 2020 at 2:32 | |||||
| Aug 11, 2020 at 9:47 | audit | First posts | |||
| Aug 11, 2020 at 9:47 | |||||
| Aug 3, 2020 at 12:58 | history | edited | Hans-Martin Mosner | CC BY-SA 4.0 |
added another good suggestion from comment.
|
| Aug 3, 2020 at 12:35 | comment | added | Ismael Miguel | @Hans-MartinMosner You are right. I still think that a cancel example could improve the last example. Something like ` "cancel":"example.com/jobs/123/cancel"` could be enough for an example. What do you think? | |
| Aug 3, 2020 at 12:19 | comment | added | Hans-Martin Mosner | @IsmaelMiguel Yes, these are details that you will need to decide, there's a lot of room for improvement. Regarding the cancel action, I'm not fully sure which option is best. For cancellation of the complete job, I see different options: one would be a "cancel" link, another would be more RESTful by patching the "status" field of the job. This would also enable interrupting a long-running job when there is no current interaction. At the end of the day, it needs to work for your application, so you got to decide how you implement it. | |
| Aug 3, 2020 at 10:57 | comment | added | Ismael Miguel |
This is such a clean, easy and elegant solution to implement. I was expecting something extremelly more complicated. Just one small nitpick: where's the cancel link? One solution I see could be to implement an "actions": { ... } object or similar, where it could be "actions": {"continue": "...", "cancel": " ... "}. In the future, if more actions are required, you can just add them there. And the status could be changed to "action-required". An example of an extra action is asking a file upload for a task that failed to fetch a remote file. Or an option to cancel or retry.
|
|
| Aug 2, 2020 at 18:02 | history | edited | Hans-Martin Mosner | CC BY-SA 4.0 |
integrated the suggestion given by @NPSF3000
|
| S Aug 2, 2020 at 17:58 | history | suggested | ruohola | CC BY-SA 4.0 |
Correct name of status code
|
| Aug 2, 2020 at 17:14 | review | Suggested edits | |||
| S Aug 2, 2020 at 17:58 | |||||
| Aug 2, 2020 at 0:33 | comment | added | NPSF3000 |
Adding some sort of idempotency token to the continue could be a good idea for a production system.
|
|
| Aug 2, 2020 at 0:23 | comment | added | WorldSEnder | @BlueRaja-DannyPflughoeft that might make sense when you want to clean up jobs but keep results available, separately. You could also reuse a previously computed result, in some applications. You might also want to serve job statistics, or use different security policies for the result and the job itself. | |
| Aug 2, 2020 at 0:04 | comment | added | BlueRaja - Danny Pflughoeft |
Why would result be another URL, and not just the result?
|
|
| Aug 1, 2020 at 18:37 | comment | added | Hans-Martin Mosner | @HenryM thanks for the reference, indeed a good read. | |
| Aug 1, 2020 at 17:56 | comment | added | HenryM | More information in How to manage state in REST | |
| Aug 1, 2020 at 15:37 | vote | accept | meci | ||
| Aug 1, 2020 at 15:31 | comment | added | Avner Shahar-Kashtan | Excellent answer, which should get more focus on the opening paragraph's core: modeling your API might require you to have a different model than your business process - you might consider the entities "operation" and "result" as your business operations, but your rest API needs to model "job" as an entity. | |
| Aug 1, 2020 at 7:04 | history | answered | Hans-Martin Mosner | CC BY-SA 4.0 |