-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
723 changed files
with
26,482 additions
and
23,934 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,20 @@ | ||
<?php | ||
|
||
/** | ||
* Using this for testing the traditional setup without creating modules and other protocols on the starter project | ||
*/ | ||
use Suphle\Server\ModuleWorkerAccessor; | ||
/** | ||
* Using this for testing the traditional setup without creating modules and other protocols on the starter project | ||
*/ | ||
use Suphle\Server\ModuleWorkerAccessor; | ||
|
||
use Suphle\Tests\Mocks\PublishedTestModules; | ||
use Suphle\Tests\Mocks\PublishedTestModules; | ||
|
||
require_once "vendor/autoload.php"; | ||
require_once "vendor/autoload.php"; | ||
|
||
$writeHeaders = php_sapi_name() !== "cli"; | ||
$writeHeaders = php_sapi_name() !== "cli"; | ||
|
||
echo (new ModuleWorkerAccessor(new PublishedTestModules, true)) | ||
echo (new ModuleWorkerAccessor(new PublishedTestModules(), true)) | ||
|
||
->buildIdentifier()->getRequestRenderer( | ||
|
||
$_GET["suphle_path"], $writeHeaders | ||
) | ||
->render(); | ||
?> | ||
->buildIdentifier()->getRequestRenderer( | ||
$_GET["suphle_path"], | ||
$writeHeaders | ||
) | ||
->render(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
<?php | ||
use Suphle\Server\ModuleWorkerAccessor; | ||
|
||
use Suphle\Tests\Mocks\PublishedTestModules; | ||
use Suphle\Server\ModuleWorkerAccessor; | ||
|
||
require_once "vendor/autoload.php"; | ||
use Suphle\Tests\Mocks\PublishedTestModules; | ||
|
||
/** | ||
* This is for use when handling traditional requests i.e. without RR | ||
*/ | ||
$handlerIdentifier = new PublishedTestModules; | ||
require_once "vendor/autoload.php"; | ||
|
||
echo("Booting Modules...\n"); | ||
/** | ||
* This is for use when handling traditional requests i.e. without RR | ||
*/ | ||
$handlerIdentifier = new PublishedTestModules(); | ||
|
||
$accessor = (new ModuleWorkerAccessor($handlerIdentifier, false)) | ||
echo("Booting Modules...\n"); | ||
|
||
->buildIdentifier(); | ||
$accessor = (new ModuleWorkerAccessor($handlerIdentifier, false)) | ||
|
||
echo("Listening for requests...\n"); | ||
->buildIdentifier(); | ||
|
||
$accessor->getQueueWorker()->processTasks(); | ||
?> | ||
echo("Listening for requests...\n"); | ||
|
||
$accessor->getQueueWorker()->processTasks(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,66 @@ | ||
<?php | ||
namespace Suphle\Adapters\Cache; | ||
|
||
use Suphle\Contracts\IO\CacheManager; | ||
namespace Suphle\Adapters\Cache; | ||
|
||
use Exception; | ||
use Suphle\Contracts\IO\CacheManager; | ||
|
||
class InMemoryCache implements CacheManager { | ||
use Exception; | ||
|
||
protected array $store = [], $tags = []; | ||
class InMemoryCache implements CacheManager | ||
{ | ||
protected array $store = []; | ||
protected array $tags = []; | ||
|
||
public function setupClient ():void { | ||
public function setupClient(): void | ||
{ | ||
|
||
// error 404: no client to setup | ||
} | ||
// error 404: no client to setup | ||
} | ||
|
||
public function getItem (string $key, callable $storeOnAbsence = null) { | ||
public function getItem(string $key, callable $storeOnAbsence = null) | ||
{ | ||
|
||
if (array_key_exists($key, $this->store)) | ||
if (array_key_exists($key, $this->store)) { | ||
|
||
return $this->store[$key]; | ||
return $this->store[$key]; | ||
} | ||
|
||
if (is_null($storeOnAbsence)) return; | ||
if (is_null($storeOnAbsence)) { | ||
return; | ||
} | ||
|
||
$toStore = $storeOnAbsence(); | ||
$toStore = $storeOnAbsence(); | ||
|
||
if (is_null($toStore)) | ||
if (is_null($toStore)) { | ||
|
||
throw new Exception("Cache data source cannot return null"); | ||
throw new Exception("Cache data source cannot return null"); | ||
} | ||
|
||
$this->saveItem($key, $toStore); | ||
$this->saveItem($key, $toStore); | ||
|
||
return $toStore; | ||
} | ||
return $toStore; | ||
} | ||
|
||
public function saveItem (string $key, $data):void { | ||
public function saveItem(string $key, $data): void | ||
{ | ||
|
||
$this->store[$key] = $data; | ||
} | ||
$this->store[$key] = $data; | ||
} | ||
|
||
public function tagItem (string $key, $data):void { | ||
public function tagItem(string $key, $data): void | ||
{ | ||
|
||
if (!array_key_exists($key, $this->tags)) | ||
if (!array_key_exists($key, $this->tags)) { | ||
|
||
$this->tags[$key] = []; | ||
$this->tags[$key] = []; | ||
} | ||
|
||
$this->tags[$key][] = $data; | ||
} | ||
$this->tags[$key][] = $data; | ||
} | ||
|
||
public function deleteItem (string $key) { | ||
public function deleteItem(string $key) | ||
{ | ||
|
||
unset($this->store[$key]); | ||
} | ||
} | ||
?> | ||
unset($this->store[$key]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,84 @@ | ||
<?php | ||
namespace Suphle\Adapters\Cache; | ||
|
||
use Suphle\Contracts\{IO\CacheManager, Config\CacheClient as CacheConfig}; | ||
namespace Suphle\Adapters\Cache; | ||
|
||
use Predis\Client; | ||
use Suphle\Contracts\{IO\CacheManager, Config\CacheClient as CacheConfig}; | ||
|
||
use Exception; | ||
use Predis\Client; | ||
|
||
class PredisAdapter implements CacheManager { | ||
use Exception; | ||
|
||
final const TAG_KEY = "_reserved_key_tags"; | ||
class PredisAdapter implements CacheManager | ||
{ | ||
final public const TAG_KEY = "_reserved_key_tags"; | ||
|
||
protected Client $client; | ||
protected Client $client; | ||
|
||
public function __construct ( | ||
public function __construct( | ||
protected readonly CacheConfig $cacheConfig | ||
) { | ||
|
||
protected readonly CacheConfig $cacheConfig | ||
) { | ||
// | ||
} | ||
|
||
// | ||
} | ||
public function setupClient(): void | ||
{ | ||
|
||
public function setupClient ():void { | ||
$this->client = new Client($this->cacheConfig->getCredentials()); | ||
} | ||
|
||
$this->client = new Client($this->cacheConfig->getCredentials()); | ||
} | ||
public function getItem(string $key, callable $storeOnAbsence = null) | ||
{ | ||
|
||
public function getItem (string $key, callable $storeOnAbsence = null) { | ||
$foundData = $this->client->get($key); | ||
|
||
$foundData = $this->client->get($key); | ||
if (!is_null($foundData) || is_null($storeOnAbsence)) { | ||
|
||
if (!is_null($foundData) || is_null($storeOnAbsence)) | ||
return $foundData; | ||
} | ||
|
||
return $foundData; | ||
$toStore = $storeOnAbsence(); | ||
|
||
$toStore = $storeOnAbsence(); | ||
if (is_null($toStore)) { | ||
|
||
if (is_null($toStore)) | ||
throw new Exception("Cache data source cannot return null"); | ||
} | ||
|
||
throw new Exception("Cache data source cannot return null"); | ||
$this->saveItem($key, $toStore); | ||
|
||
$this->saveItem($key, $toStore); | ||
return $toStore; | ||
} | ||
|
||
return $toStore; | ||
} | ||
public function saveItem(string $key, $data): void | ||
{ | ||
|
||
public function saveItem (string $key, $data):void { | ||
$this->client->set($key, $data); | ||
} | ||
|
||
$this->client->set($key, $data); | ||
} | ||
public function tagItem(string $key, $data): void | ||
{ | ||
|
||
public function tagItem (string $key, $data):void { | ||
$dataNode = $this->client; | ||
|
||
$dataNode = $this->client; | ||
$allTags = $dataNode->get(self::TAG_KEY); | ||
|
||
$allTags = $dataNode->get(self::TAG_KEY); | ||
if (is_null($allTags)) { | ||
$allTags = []; | ||
} | ||
|
||
if (is_null($allTags)) $allTags = []; | ||
if (!array_key_exists($key, $allTags)) { | ||
|
||
if (!array_key_exists($key, $allTags)) | ||
$allTags[$key] = []; | ||
} | ||
|
||
$allTags[$key] = []; | ||
$allTags[$key][] = $data; | ||
|
||
$allTags[$key][] = $data; | ||
$dataNode->set(self::TAG_KEY, $allTags); | ||
} | ||
|
||
$dataNode->set(self::TAG_KEY, $allTags); | ||
} | ||
public function deleteItem(string $key) | ||
{ | ||
|
||
public function deleteItem (string $key) { | ||
|
||
$this->client->set($key, null); | ||
} | ||
} | ||
?> | ||
$this->client->set($key, null); | ||
} | ||
} |
Oops, something went wrong.