-
Notifications
You must be signed in to change notification settings - Fork 4
refactor: extract runtimes #200
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
base: main
Are you sure you want to change the base?
Conversation
7b6847f to
49a38f7
Compare
49a38f7 to
0c84250
Compare
| if ($this->runtimes->exists($runtimeName)) { | ||
| $existingRuntime = $this->runtimes->get($runtimeName); | ||
| if ($existingRuntime !== null && $existingRuntime->status === 'pending') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is one extra operation here. exists and get() !== null is same result, I think
| 0, | ||
| $image, | ||
| 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For those numbers, better code readability would be named params
| if ($runtime !== null) { | ||
| $runtime->updated = \microtime(true); | ||
| $runtime->status = 'Up ' . \round($duration, 2) . 's'; | ||
| $runtime->initialised = 1; | ||
|
|
||
| $this->runtimes->set($runtimeName, $runtime); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get&set are not atomic, but I think swoole tables can be atomic. maybe some kind of update or setProperty. Let's chcek, could be nice improvement here
| return $createdNetworks; | ||
| } | ||
|
|
||
| public function getRuntimes(): mixed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need those getRuntimes and getRuntime methods anymore? If needed, could Runtimes become a registry item, or resource of request, to prevent need for those methods?
Swoole\Tableusage into a dedicatedRuntimesrepository +Runtimedto.nikic/php-parser.Conceptually this is enables coroutines and paying down some technical debt: it localises the Swoole bits, makes Docker easier to reason about, and gives a single abstraction for “active runtimes”.