Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
|||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace LambdaTwelve\OneRecord\Server\Spi; |
| 6 | |
| 7 | /** |
| 8 | * The host's transaction boundary. Accepting a change saves a revision, saves |
| 9 | * the request, rejects stale siblings and queues notifications: several store |
| 10 | * calls that must stand or fall together. The server runs every mutating |
| 11 | * request through `run()`, and DataHolder and ActionRequests run each of |
| 12 | * their operations through it, so a host that binds its database transaction |
| 13 | * here gets atomicity everywhere without inspecting status codes. |
| 14 | * |
| 15 | * Calls nest: an operation inside a request is already inside the request's |
| 16 | * unit, and DataHolder::change() runs create and accept as one. An |
| 17 | * implementation must therefore either join an open unit (savepoints, or a |
| 18 | * depth counter) or tolerate nesting the way the identity implementation does. |
| 19 | * |
| 20 | * Exceptions thrown by `$work` propagate after the unit is rolled back; a |
| 21 | * return value is committed and returned. |
| 22 | */ |
| 23 | interface UnitOfWork |
| 24 | { |
| 25 | /** |
| 26 | * @template T |
| 27 | * @param callable(): T $work |
| 28 | * @return T |
| 29 | */ |
| 30 | public function run(callable $work): mixed; |
| 31 | } |