Skip to content

Commit

Permalink
Merge pull request #35 from msmakouz/short-default-config
Browse files Browse the repository at this point in the history
Simplify default config
  • Loading branch information
butschster authored Jul 28, 2022
2 parents 36878c8 + 124a6a6 commit 2b42333
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 275 deletions.
24 changes: 23 additions & 1 deletion src/Configuration/Plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,34 @@

namespace Spiral\RoadRunner\Console\Configuration;

use Spiral\RoadRunner\Console\Configuration\Section\Http;
use Spiral\RoadRunner\Console\Configuration\Section\Jobs;
use Spiral\RoadRunner\Console\Configuration\Section\Kv;
use Spiral\RoadRunner\Console\Configuration\Section\Metrics;
use Spiral\RoadRunner\Console\Configuration\Section\Rpc;
use Spiral\RoadRunner\Console\Configuration\Section\SectionInterface;
use Spiral\RoadRunner\Console\Configuration\Section\Server;
use Spiral\RoadRunner\Console\Configuration\Section\Version;
use Spiral\Tokenizer\ClassLocator;
use Symfony\Component\Finder\Finder;

final class Plugins
{
/**
* @psalm-var array<class-string>
*
* Default plugins in a class-string format.
*/
private array $defaultPlugins = [
Version::class,
Rpc::class,
Server::class,
Http::class,
Jobs::class,
Kv::class,
Metrics::class,
];

/**
* @var string[]
*
Expand Down Expand Up @@ -51,7 +73,7 @@ public static function fromPreset(string $preset): self
public function getPlugins(): array
{
if ($this->requestedPlugins === []) {
return $this->available;
return $this->defaultPlugins;
}

$plugins = [];
Expand Down
115 changes: 7 additions & 108 deletions src/Configuration/Section/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,121 +12,20 @@ public function render(): array
{
return [
self::NAME => [
'address' => '127.0.0.1:8080',
'internal_error_code' => 505,
'access_logs' => false,
'max_request_size' => 256,
'address' => '0.0.0.0:8080',
'middleware' => [
'headers',
'gzip'
],
'trusted_subnets' => [
'10.0.0.0/8',
'127.0.0.0/8',
'172.16.0.0/12',
'192.168.0.0/16',
'::1/128',
'fc00::/7',
'fe80::/10'
],
'new_relic' => [
'app_name' => 'app',
'license_key' => 'key'
],
'cache' => [
'driver' => 'memory',
'cache_methods' => [
'GET',
'HEAD',
'POST'
],
'config' => []
],
'uploads' => [
'dir' => '/tmp',
'forbid' => [
'.php',
'.exe',
'.bat',
'.sh'
],
'allow' => [
'.html',
'.aaa'
]
],
'headers' => [
'cors' => [
'allowed_origin' => '*',
'allowed_headers' => '*',
'allowed_methods' => 'GET,POST,PUT,DELETE',
'allow_credentials' => true,
'exposed_headers' => 'Cache-Control,Content-Language,Content-Type,Expires,Last-Modified,Pragma',
'max_age' => 600
],
'request' => [
'input' => 'custom-header',
],
'response' => [
'X-Powered-By' => 'RoadRunner'
]
'gzip',
'static'
],
'static' => [
'dir' => '.',
'forbid' => [''],
'calculate_etag' => false,
'weak' => false,
'allow' => [
'.txt',
'.php'
],
'request' => [
'input' => 'custom-header'
],
'response' => [
'output' => 'output-header'
]
'dir' => 'public',
'forbid' => ['.php', '.htaccess'],
],
'pool' => [
'debug' => false,
'command' => 'php my-super-app.php',
'num_workers' => 0,
'max_jobs' => 64,
'allocate_timeout' => '60s',
'destroy_timeout' => '60s',
'num_workers' => 1,
'supervisor' => [
'watch_tick' => '1s',
'ttl' => '0s',
'idle_ttl' => '10s',
'max_worker_memory' => 128,
'exec_ttl' => '60s'
'max_worker_memory' => 100
]
],
'ssl' => [
'address' => '127.0.0.1:443',
'acme' => [
'certs_dir' => 'rr_le_certs',
'email' => 'you-email-here@email',
'alt_http_port' => 80,
'alt_tlsalpn_port' => 443,
'challenge_type' => 'http-01',
'use_production_endpoint' => true,
'domains' => [
'your-cool-domain.here',
'your-second-domain.here'
]
],
'redirect' => true,
'cert' => '/ssl/server.crt',
'key' => '/ssl/server.key',
'root_ca' => '/ssl/root.crt'
],
'fcgi' => [
'address' => 'tcp://0.0.0.0:7921'
],
'http2' => [
'h2c' => false,
'max_concurrent_streams' => 128
]
]
];
Expand Down
93 changes: 3 additions & 90 deletions src/Configuration/Section/Jobs.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,98 +12,11 @@ public function render(): array
{
return [
self::NAME => [
'num_pollers' => 32,
'pipeline_size' => 100000,
'pool' => [
'command' => '',
'num_workers' => 10,
'max_jobs' => 0,
'allocate_timeout' => '60s',
'destroy_timeout' => '60s'
'num_workers' => 2,
'max_worker_memory' => 100
],
'pipelines' => [
'test-local' => [
'driver' => 'memory',
'config' => [
'priority' => 10,
'prefetch' => 10000
]
],
'test-local-1' => [
'driver' => 'boltdb',
'config' => [
'file' => 'path/to/rr.db',
'priority' => 10,
'prefetch' => 10000
]
],
'test-local-2' => [
'driver' => 'amqp',
'config' => [
'prefetch' => 10,
'priority' => 1,
'durable' => false,
'delete_queue_on_stop' => false,
'queue' => 'test-1-queue',
'exchange' => 'default',
'exchange_type' => 'direct',
'routing_key' => 'test',
'exclusive' => false,
'multiple_ack' => false,
'requeue_on_fail' => false
]
],
'test-local-3' => [
'driver' => 'beanstalk',
'config' => [
'priority' => 11,
'tube_priority' => 1,
'tube' => 'default-1',
'reserve_timeout' => '10s'
]
],
'test-local-4' => [
'driver' => 'sqs',
'config' => [
'priority' => 10,
'prefetch' => 10,
'visibility_timeout' => 0,
'wait_time_seconds' => 0,
'queue' => 'default',
'attributes' => [
'DelaySeconds' => 0,
'MaximumMessageSize' => 262144,
'MessageRetentionPeriod' => 345600,
'ReceiveMessageWaitTimeSeconds' => 0,
'VisibilityTimeout' => 30
],
'tags' => [
'test' => 'tag'
]
]
],
'test-local-5' => [
'driver' => 'nats',
'config' => [
'priority' => 2,
'prefetch' => 100,
'subject' => 'default',
'stream' => 'foo',
'deliver_new' => true,
'rate_limit' => 100,
'delete_stream_on_stop' => false,
'delete_after_ack' => false
]
]
],
'consume' => [
'test-local',
'test-local-1',
'test-local-2',
'test-local-3',
'test-local-4',
'test-local-5'
]
'consume' => []
]
];
}
Expand Down
46 changes: 5 additions & 41 deletions src/Configuration/Section/Kv.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,54 +12,18 @@ public function render(): array
{
return [
self::NAME => [
'boltdb-south' => [
'driver' => 'boltdb',
'config' => [
'file' => 'rr.db',
'permissions' => 0777,
'interval' => 40
]
],
'us-central-kv' => [
'driver' => 'memcached',
'local' => [
'driver' => 'memory',
'config' => [
'addr' => [
'localhost:11211'
]
'interval' => 60
]
],
'fast-kv-fr' => [
'redis' => [
'driver' => 'redis',
'config' => [
'addrs' => [
'localhost:6379'
],
'master_name' => '',
'username' => '',
'password' => '',
'db' => 0,
'sentinel_password' => '',
'route_by_latency' => false,
'route_randomly' => false,
'dial_timeout' => 0,
'max_retries' => 1,
'min_retry_backoff' => 0,
'max_retry_backoff' => 0,
'pool_size' => 0,
'min_idle_conns' => 0,
'max_conn_age' => 0,
'read_timeout' => 0,
'write_timeout' => 0,
'pool_timeout' => 0,
'idle_timeout' => 0,
'idle_check_freq' => 0,
'read_only' => false
]
],
'local-memory' => [
'driver' => 'memory',
'config' => [
'interval' => 1
]
]
]
]
Expand Down
25 changes: 1 addition & 24 deletions src/Configuration/Section/Metrics.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,7 @@ public function render(): array
{
return [
self::NAME => [
'address' => '127.0.0.1:2112',
'collect' => [
'app_metric' => [
'type' => 'histogram',
'help' => 'Custom application metric',
'labels' => [
'type'
],
'buckets' => [
0.1,
0.2,
0.3,
1.0
],
'objectives' => [
[
'1.4' => 2.3
],
[
'2.0' => 1.4
]
]
]
]
'address' => 'localhost:2112'
]
];
}
Expand Down
11 changes: 2 additions & 9 deletions src/Configuration/Section/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,8 @@ public function render(): array
{
return [
self::NAME => [
'on_init' => [
'command' => 'any php or script here',
'exec_timeout' => '20s',
],
'command' => 'php psr-worker.php',
'user' => '',
'group' => '',
'relay' => 'pipes',
'relay_timeout' => '60s'
'command' => 'php app.php',
'relay' => 'pipes'
]
];
}
Expand Down
5 changes: 3 additions & 2 deletions src/DownloadProtocBinaryCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,9 @@ private function findAsset(

foreach ($filtered as $release) {
$asset = $release->getAssets()
->filter(static fn (AssetInterface $asset): bool =>
0 === \strncmp($asset->getName(), 'protoc-gen-php-grpc', \strlen('protoc-gen-php-grpc'))
->filter(
static fn (AssetInterface $asset): bool =>
\str_starts_with($asset->getName(), 'protoc-gen-php-grpc')
)
->whereArchitecture($archOption)
->whereOperatingSystem($osOption)
Expand Down

0 comments on commit 2b42333

Please sign in to comment.