mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Save executor stats into cache
This commit is contained in:
@@ -10,6 +10,9 @@ class Random extends Adapter
|
||||
{
|
||||
$executors = $this->getExecutors();
|
||||
$executor = $executors[\array_rand($executors)] ?? null;
|
||||
|
||||
\var_dump($executor);
|
||||
|
||||
return $executor ?? null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ use FunctionsProxy\Adapter;
|
||||
|
||||
class RoundRobin extends Adapter
|
||||
{
|
||||
private $currentIndex = 0; // TODO: Put into redis to share across proxies
|
||||
private $currentIndex = 0; // TODO: @Meldiron Put into redis to share across proxies
|
||||
|
||||
public function getNextExecutor(): array
|
||||
{
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace FunctionsProxy\Adapter;
|
||||
|
||||
use FunctionsProxy\Adapter;
|
||||
|
||||
class UsageBased extends Adapter
|
||||
{
|
||||
public function getNextExecutor(): array
|
||||
{
|
||||
$executors = $this->getExecutors();
|
||||
|
||||
/*
|
||||
appwrite-functions-proxy | array(3) {
|
||||
appwrite-functions-proxy | ["id"]=>
|
||||
appwrite-functions-proxy | string(4) "exc2"
|
||||
appwrite-functions-proxy | ["hostname"]=>
|
||||
appwrite-functions-proxy | string(18) "appwrite-executor2"
|
||||
appwrite-functions-proxy | ["state"]=>
|
||||
appwrite-functions-proxy | array(2) {
|
||||
appwrite-functions-proxy | ["status"]=>
|
||||
appwrite-functions-proxy | string(6) "online"
|
||||
appwrite-functions-proxy | ["stats"]=>
|
||||
appwrite-functions-proxy | array(3) {
|
||||
appwrite-functions-proxy | ["status"]=>
|
||||
appwrite-functions-proxy | string(4) "pass"
|
||||
appwrite-functions-proxy | ["hostUsage"]=>
|
||||
appwrite-functions-proxy | float(0.348125)
|
||||
appwrite-functions-proxy | ["functionsUsage"]=>
|
||||
appwrite-functions-proxy | array(0) {
|
||||
appwrite-functions-proxy | }
|
||||
appwrite-functions-proxy | }
|
||||
appwrite-functions-proxy | }
|
||||
appwrite-functions-proxy | }
|
||||
*/
|
||||
|
||||
// TODO: @Meldiron Proper functionality
|
||||
// TODO: @Meldiron Use this adapter and test it
|
||||
|
||||
$executor = $executors[\array_rand($executors)] ?? null;
|
||||
return $executor ?? null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user