-
-
Notifications
You must be signed in to change notification settings - Fork 174
feat(core)!: worker mode support #2172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
8a739b1
Make cookie and session resettable
brendt cae050f
Support persistent database connections
brendt 0085448
Add TODO
brendt aac89f9
Add tests
brendt 508ff94
Move session auth reset
brendt c1e31c1
Move session auth reset
brendt a7858aa
QA
brendt 2b8bf17
QA
brendt e32b15c
Small fixes
brendt fa8ed77
QA
brendt 475b11a
Add WorkerModeApplication
brendt 422669f
Add WorkerModeApplication
brendt ef6dd0e
Add deferred tasks reset
brendt 81eba07
Add deferred tasks reset
brendt a62679c
Handle transactions during reset
brendt ff2a6fd
Kernel cleanup
brendt b7df50c
QA
brendt 6a91e66
Refactor connection
brendt ac08a69
Add rectors
brendt a9bd32a
QA
brendt 07e5732
QA
brendt c1ffeca
Improve kernel implementation
brendt e48e703
Improve kernel implementation
brendt 79ec2e9
Fix tests
brendt d0f2337
Prevent stale connections
brendt 4551bce
Fix
brendt 068c91f
QA
brendt 5d5f19f
QA
brendt d61fd96
QA
brendt 38f0919
QA
brendt 845c4c6
wip
brendt 4a2bd84
wip
brendt 63728b0
wip
brendt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
packages/auth/src/Authentication/SessionAuthenticatorReset.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| <?php | ||
|
|
||
| namespace Tempest\Auth\Authentication; | ||
|
|
||
| use Tempest\Container\Resettable; | ||
|
|
||
| final readonly class SessionAuthenticatorReset implements Resettable | ||
| { | ||
| public function __construct( | ||
| private SessionAuthenticator $sessionAuthenticator, | ||
| ) {} | ||
|
|
||
| public function reset(): void | ||
| { | ||
| $this->sessionAuthenticator->clearCurrent(); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| <?php | ||
|
|
||
| namespace Tempest\Core; | ||
|
|
||
| use Tempest\Container\Container; | ||
| use Tempest\Container\Resettable; | ||
|
|
||
| final readonly class DeferredTasksReset implements Resettable | ||
| { | ||
| public function __construct( | ||
| private Container $container, | ||
| ) {} | ||
|
|
||
| public function reset(): void | ||
| { | ||
| $this->container->unregister(DeferredTasks::class); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,9 @@ | |
|
|
||
| enum KernelEvent | ||
| { | ||
| case SHUTTING_DOWN; | ||
| case RESETTING; | ||
| case RESET; | ||
| case BOOTED; | ||
| case SHUTDOWN; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| <?php | ||
|
|
||
| namespace Tempest\Database\Connection; | ||
|
|
||
| use Tempest\Container\Container; | ||
| use Tempest\Container\GenericContainer; | ||
| use Tempest\Container\Resettable; | ||
| use Tempest\Database\Exceptions\CouldNotResetConnection; | ||
|
|
||
| final readonly class ConnectionReset implements Resettable | ||
| { | ||
| public function __construct( | ||
| private Container $container, | ||
| ) {} | ||
|
|
||
| public function reset(): void | ||
| { | ||
| // Manually looping over the connection singletons so that we can check whether they still have an active transaction | ||
| if ($this->container instanceof GenericContainer) { | ||
| $connections = $this->container->getSingletons(Connection::class); | ||
|
|
||
| foreach ($connections as $connection) { | ||
| if (! $connection instanceof Connection) { | ||
| continue; | ||
| } | ||
|
|
||
| if ($connection->inTransaction()) { | ||
| throw new CouldNotResetConnection("There's still an active transaction, make sure to close it before ending the request"); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| $this->container->unregister(Connection::class, tagged: true); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| <?php | ||
|
|
||
| namespace Tempest\Database; | ||
|
|
||
| use Tempest\Container\Container; | ||
| use Tempest\Container\Resettable; | ||
|
|
||
| final readonly class DatabaseReset implements Resettable | ||
| { | ||
| public function __construct( | ||
| private Container $container, | ||
| ) {} | ||
|
|
||
| public function reset(): void | ||
| { | ||
| $this->container->unregister(Database::class, tagged: true); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.