Reputation: 3163
I have a REST API which is used by few users and which performs CRUD operations in yum repositories. The repository creation operation takes some time. From what I've read in the web, returning a 202 status code and creating a task resource from which user can query creation status is the best option. However, I think this is overkill for my simple REST API. What are the cons of making the repository creation synchronous? The only one I think of is that I'll have to tweak HTTP request timeout value.
Upvotes: 1
Views: 2858
Reputation: 26157
Another possible solution to add a websocket endpoint and receive the events (related to the actual client) from there. I don't think there are any cons except of the connection timeout and the increased load of the webserver ofc. Since this is a rare event (I guess) the only thing you should worry about is the timeout.
Upvotes: 0
Reputation: 6066
You're keeping a HTTP connection open for a long(er) time so it's more resource consuming and it doesn't scale well. It's also less reliable if there are network problems.
It really depends on your use case. Maybe these downsides don't matter too much in your case? You can decide best.
Upvotes: 2