Skip to content

Conversation

@loks0n
Copy link
Member

@loks0n loks0n commented Nov 22, 2025

  • Extracting the Swoole\Table usage into a dedicated Runtimes repository + Runtime dto.
  • Injecting this shared repository into Docker so it’s initialised in the master process and fork-safe.
  • Adding unit tests around the new types and tweaking phpunit suites and bumping 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”.

@loks0n loks0n force-pushed the refactor-extract-runtimes branch from 7b6847f to 49a38f7 Compare November 22, 2025 10:40
@loks0n loks0n force-pushed the refactor-extract-runtimes branch from 49a38f7 to 0c84250 Compare November 22, 2025 11:01
Comment on lines +401 to +403
if ($this->runtimes->exists($runtimeName)) {
$existingRuntime = $this->runtimes->get($runtimeName);
if ($existingRuntime !== null && $existingRuntime->status === 'pending') {
Copy link
Contributor

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

Comment on lines +422 to +424
0,
$image,
0,
Copy link
Contributor

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

Comment on lines +594 to +600
if ($runtime !== null) {
$runtime->updated = \microtime(true);
$runtime->status = 'Up ' . \round($duration, 2) . 's';
$runtime->initialised = 1;

$this->runtimes->set($runtimeName, $runtime);
}
Copy link
Contributor

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
Copy link
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants