|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Utopia\Proxy\Server\HTTP; |
| 4 | + |
| 5 | +class Config |
| 6 | +{ |
| 7 | + public readonly int $reactorNum; |
| 8 | + |
| 9 | + public function __construct( |
| 10 | + public readonly string $host = '0.0.0.0', |
| 11 | + public readonly int $port = 80, |
| 12 | + public readonly int $workers = 16, |
| 13 | + public readonly int $maxConnections = 100_000, |
| 14 | + public readonly int $maxCoroutine = 100_000, |
| 15 | + public readonly int $socketBufferSize = 2 * 1024 * 1024, |
| 16 | + public readonly int $bufferOutputSize = 2 * 1024 * 1024, |
| 17 | + public readonly bool $enableCoroutine = true, |
| 18 | + public readonly int $maxWaitTime = 60, |
| 19 | + public readonly int $serverMode = SWOOLE_PROCESS, |
| 20 | + ?int $reactorNum = null, |
| 21 | + public readonly int $dispatchMode = 2, |
| 22 | + public readonly bool $enableReusePort = true, |
| 23 | + public readonly int $backlog = 65535, |
| 24 | + public readonly bool $parsePost = false, |
| 25 | + public readonly bool $parseCookie = false, |
| 26 | + public readonly bool $parseFiles = false, |
| 27 | + public readonly bool $compression = false, |
| 28 | + public readonly int $logLevel = SWOOLE_LOG_ERROR, |
| 29 | + public readonly int $timeout = 30, |
| 30 | + public readonly bool $keepAlive = true, |
| 31 | + public readonly int $poolSize = 1024, |
| 32 | + public readonly float $poolTimeout = 0.001, |
| 33 | + public readonly bool $telemetry = true, |
| 34 | + public readonly bool $fastPath = false, |
| 35 | + public readonly bool $fastPathAssumeOk = false, |
| 36 | + public readonly ?string $fixedBackend = null, |
| 37 | + public readonly ?string $directResponse = null, |
| 38 | + public readonly int $directResponseStatus = 200, |
| 39 | + public readonly int $keepaliveTimeout = 60, |
| 40 | + public readonly bool $httpProtocol = true, |
| 41 | + public readonly bool $http2Protocol = false, |
| 42 | + public readonly int $maxRequest = 0, |
| 43 | + public readonly bool $rawBackend = false, |
| 44 | + public readonly bool $rawBackendAssumeOk = false, |
| 45 | + public readonly bool $skipValidation = false, |
| 46 | + public readonly ?\Closure $requestHandler = null, |
| 47 | + public readonly ?\Closure $workerStart = null, |
| 48 | + ) { |
| 49 | + $this->reactorNum = $reactorNum ?? swoole_cpu_num() * 2; |
| 50 | + } |
| 51 | +} |
0 commit comments