Skip to content

Commit

Permalink
DDEV-1965 octane swoole tables storage
Browse files Browse the repository at this point in the history
  • Loading branch information
Vadim Davydenko committed Nov 14, 2024
1 parent d8caade commit 3496205
Show file tree
Hide file tree
Showing 4 changed files with 619 additions and 1 deletion.
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@
"php": "^8.1",
"ext-redis": "*",
"laravel/framework": "^9.0 || ^10.0 || ^11.0",
"laravel/octane": "^2.5",
"promphp/prometheus_client_php": "^2.6"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.2",
"nunomaduro/collision": "^6.0 || ^7.0 || ^8.1",
"orchestra/testbench": "^7.0 || ^8.0 || ^9.0",
"pestphp/pest": "^1.22 || ^2.0",
"pestphp/pest-plugin-laravel": "^1.1 || ^2.0",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan": "^1.11",
"spaze/phpstan-disallowed-calls": "^2.15",
"orchestra/testbench": "^7.0 || ^8.0 || ^9.0"
"swoole/ide-helper": "~5.0.0"
},
"autoload": {
"psr-4": {
Expand Down
51 changes: 51 additions & 0 deletions config/octane.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

return [

/*
|--------------------------------------------------------------------------
| Octane Swoole Tables
|--------------------------------------------------------------------------
|
| While using Swoole, you may define additional tables as required by the
| application. These tables can be used to store data that needs to be
| quickly accessed by other workers on the particular Swoole server.
|
*/

'tables' => [
'gauges:1000' => [
'meta' => 'string:10000',
'valueKeys' => 'string:10000',
],
'gauge_values:100000' => [
'value' => 'float',
],

'сounters:1000' => [
'meta' => 'string:10000',
'valueKeys' => 'string:10000',
],
'сounter_values:100000' => [
'value' => 'float',
],

'summaries:1000' => [
'meta' => 'string:10000',
'valueKeys' => 'string:10000',
],
'summary_values:100000' => [
'labelValues' => 'string:10000',
'sampleTimes' => 'string:10000',
'sampleValues' => 'string:10000',
],

'histograms:1000' => [
'meta' => 'string:10000',
'valueKeys' => 'string:10000',
],
'histogram_values:100000' => [
'value' => 'float',
],
],
];
3 changes: 3 additions & 0 deletions src/MetricsBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Ensi\LaravelPrometheus\Metrics\Summary;
use Ensi\LaravelPrometheus\OnDemandMetrics\OnDemandMetric;
use Ensi\LaravelPrometheus\Storage\NullStorage;
use Ensi\LaravelPrometheus\Storage\OctaneCache;
use Ensi\LaravelPrometheus\Storage\Redis;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Redis as RedisManager;
Expand Down Expand Up @@ -179,6 +180,8 @@ private function getStorage(): Adapter
return new APCng($this->config['apcu-ng']['prefix']);
case array_key_exists('memory', $this->config):
return new InMemory();
case array_key_exists('octane-cache', $this->config):
return new OctaneCache($this->config['octane-cache']['prefix']);
case array_key_exists('null-storage', $this->config):
return new NullStorage();
}
Expand Down
Loading

0 comments on commit 3496205

Please sign in to comment.