feat(core)!: worker mode support#2172
Conversation
Benchmark ResultsComparison of Open to see the benchmark results
Generated by phpbench against commit e11dedf |
|
@laylatichy it took a little longer, but here's my draft PR to implement the resettable interface and provide persistent database connections. Would love if you could share your input and possibly tell me what I missed :) |
|
To be clear: the goal of this PR isn't to provide the worker application, I'll work on that in a separate PR. I first want to make sure I haven't missed anything obvious in the base implementation |
|
Also something that's missing compared to #1996 is the memoization reset. I don't think they need to be reset, since they only contain reflection data that never changes. In fact, I think it's better not to reset them, since resetting would decrease performance. |
|
worth noting DeferredTasks, right now you finish them in shutdown, resetting them is kinda tricky, might require different approach and db connection reset is a bit tricky with transactions, on db connection from request crashes mid transaction ping() i think returns fine, next requests reuses that transaction, but might need validating, a lot of time passed since i digged into it on the memo yeah it should stay no point in resting it with how it's used now aside from that looks good |
Wouldn't the right approach be that all transactions should be finished before ending the request? My first idea is to have a
Good point. Should we support it though? I think an easier "solution" is to not allow deferred tasks in worker mode, and force users to use async commands instead. Deferred tasks are a lazy solution anyway for those who don't want to set up async commands, but I think it's fair to assume people who chose worker mode won't mind using the command bus. WDYT? |
|
Edit: having said that, I realize we actually use deferred tasks to clean up sessions 😅 Ok I'll think about it some more |
|
Oh, actually: defer will work as expected:
That's good, it means I just have to refactor the shutdown function. 👍 |
|
Ok @laylatichy a couple more changes:
|
|
Breaking changes
Tempest\Core\Kernel::shutdown()signatureTempest\Database\Connection::inTransaction(): boolTempest\Database\Connection::ping(): boolTempest\Database\Connection::reconnect(): voidTODO