Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

REST, Unit of Work, Business Transactions

Do I understand right that idea of "Unit of Work" conflicts with idea of "REST"?

Implementation of UoW should send to server an [ordered] set of changes objects of different types. This results in mix of PUT and DELETE verbs and URIs and cannot be done with one HTTP request in REST-style.

More generally, there is no way to implement in REST style a business transaction which covers different kinds of changes to different types of objects.

How you solve this problem? Create some special-purpose URI "/transaction" which can accept corresponding data or do something else?

like image 524
adontz Avatar asked Dec 01 '25 00:12

adontz


1 Answers

Just define a resource (and representation) that is your Unit of Work, and post it to your service for data processing -- per the HTTP specification for POST.

(POST can also be seen as the "append" verb, and you're appending an item to a conceptual work list ;) )

If you want to make it asyncronous, POST a unit of work and get some sort of ID back, then you can GET that id to see how it's progressing.

Generally, you want to break up operations like that for the client to handle, using techniques like optimistic locking, but you can always define your resource really broadly as some sort of work document if you need to.

like image 195
sea-rob Avatar answered Dec 02 '25 14:12

sea-rob



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!