Skip to content

Commit ee4fc6d

Browse files
committed
Remove worker concept
1 parent d5e2929 commit ee4fc6d

File tree

4 files changed

+0
-60
lines changed

4 files changed

+0
-60
lines changed

src/Http/Adapter.php

100644100755
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
abstract class Adapter
66
{
77
abstract public function onStart(callable $callback);
8-
abstract public function onWorkerStart(callable $callback);
98
abstract public function onRequest(callable $callback);
109
abstract public function start();
1110
}

src/Http/Adapter/FPM/Server.php

100644100755
Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ public function onStart(callable $callback)
2727
call_user_func($callback, $this);
2828
}
2929

30-
public function onWorkerStart(callable $callback)
31-
{
32-
call_user_func($callback, $this);
33-
}
34-
3530
public function start()
3631
{
3732
return;

src/Http/Adapter/Swoole/Server.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ public function onRequest(callable $callback)
3535
});
3636
}
3737

38-
public function onWorkerStart(callable $callback)
39-
{
40-
call_user_func($callback, $this);
41-
}
42-
4338
public function onStart(callable $callback)
4439
{
4540
call_user_func($callback, $this);

src/Http/Http.php

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,6 @@ class Http
9797
*/
9898
protected static array $startHooks = [];
9999

100-
/**
101-
* Worker Start hooks
102-
*
103-
* @var Hook[]
104-
*/
105-
protected static array $workerStartHooks = [];
106-
107100
/**
108101
* Request hooks
109102
*
@@ -563,13 +556,6 @@ protected function getFileMimeType(string $uri): mixed
563556
return $this->files->getFileMimeType($uri);
564557
}
565558

566-
public static function onWorkerStart(): Hook
567-
{
568-
$hook = new Hook();
569-
self::$workerStartHooks[] = $hook;
570-
return $hook;
571-
}
572-
573559
public static function onStart(): Hook
574560
{
575561
$hook = new Hook();
@@ -623,40 +609,6 @@ public function start()
623609
}
624610
});
625611

626-
$this->server->onWorkerStart(function ($server, $workerId) {
627-
$this->resources['utopia'] ??= [];
628-
$this->resources['utopia']['server'] = $server;
629-
$this->resources['utopia']['workerId'] = $workerId;
630-
631-
self::setResource('server', function () use ($server) {
632-
return $server;
633-
});
634-
self::setResource('workerId', function () use ($workerId) {
635-
return $workerId;
636-
});
637-
638-
try {
639-
640-
foreach (self::$workerStartHooks as $hook) {
641-
$arguments = $this->getArguments($hook, 'utopia', [], []);
642-
\call_user_func_array($hook->getAction(), $arguments);
643-
}
644-
} catch(\Exception $e) {
645-
self::setResource('error', fn () => $e);
646-
647-
foreach (self::$errors as $error) { // Global error hooks
648-
if (in_array('*', $error->getGroups())) {
649-
try {
650-
$arguments = $this->getArguments($error, 'utopia', [], []);
651-
\call_user_func_array($error->getAction(), $arguments);
652-
} catch (\Throwable $e) {
653-
throw new Exception('Error handler had an error: ' . $e->getMessage(), 500, $e);
654-
}
655-
}
656-
}
657-
}
658-
});
659-
660612
$this->server->start();
661613
}
662614

@@ -1004,7 +956,6 @@ public static function reset(): void
1004956
self::$init = [];
1005957
self::$shutdown = [];
1006958
self::$options = [];
1007-
self::$workerStartHooks = [];
1008959
self::$startHooks = [];
1009960
}
1010961
}

0 commit comments

Comments
 (0)