Archive: Namaste PHP AMQP framework v1.0 (2017-2020)

952 days continuous production uptime, 40k+ tp/s single node.
Original corpo Bitbucket history not included — clean archive commit.
This commit is contained in:
2026-04-05 09:49:30 -07:00
commit 373ebc8c93
1284 changed files with 409372 additions and 0 deletions

107
stubs/initTest.php Normal file
View File

@@ -0,0 +1,107 @@
<?php
/**
* This initTest.php script tests the "lite-loading" of the framework config. This is basically a pared-down version
* of the bootstrap loader missing a few initialization processes. Notably missing are the singleton instantiations
* of the static classes which, because of resM logging, add a few seconds to clients *connecting* to the framework.
*
* In other words, the bootstrap loader is heavy-duty and used to start the entire Namaste framework. This script
* helped to derive a lighter version of the bootstrap loader that removes the instantiation lag.
*
*
* @author mike@givingassistant.org
* @version 1.0.0
*
*
* HISTORY:
* ========
* 0=8-29-18 mks DB-50: original coding
*
*
*/
$eos = (isset($_SERVER['HTTP_USER_AGENT'])) ? '<br />' : PHP_EOL;
$topDir = dirname( __DIR__ );
function gt(): string
{
return('[' . date("d/m/y@H:i:s", time()) . '] [ !]TEST: ');
}
// load the files stored in the common directory
foreach(glob($topDir . '/common/*.php') as $filename) {
/** @noinspection PhpIncludeInspection */
require_once($filename);
}
$classesDir = $topDir . DIR_CLASSES;
$configDir = $topDir . DIR_CONFIG;
$amqpLib = $topDir . DIR_LIB;
$templateDir = $topDir . DIR_CLASSES . DIR_TEMPLATE;
// load the auto-loaders (composer and namaste)
/** @noinspection PhpIncludeInspection */
require($topDir . FILE_AUTOLOADER);
if(file_exists($classesDir)) {
Autoloader::register_directory($classesDir);
Autoloader::register_directory($templateDir);
}
require_once $amqpLib . '/vendor/autoload.php';
use /** @noinspection PhpUnusedAliasInspection */ PhpAmqpLib\Connection\AMQPStreamConnection;
use /** @noinspection PhpUnusedAliasInspection */ PhpAmqpLib\Channel\AMQPChannel;
use /** @noinspection PhpUnusedAliasInspection */ PhpAmqpLib\Message\AMQPMessage;
// load the base configuration
if (!gasConfig::singleton($configDir . FILE_BASE_CONFIG, FILE_TYPE_XML))
exit(gt() . 'Failed to load config singleton...' . $eos);
if (file_exists($configDir . FILE_ENV_CONFIG)) {
gasConfig::addConfig($configDir . FILE_ENV_CONFIG, FILE_TYPE_XML);
if (!gasConfig::$status)
exit(gt() . 'Failed to load/layer env configuration...' . $eos);
}
// Everything that appears above would be the new "light" loader for
// test to see if we can get a mongo-master resource w/out explicitly re-declaring the singleton for the resource manager
$mongoResource = gasResourceManager::fetchResource(RESOURCE_MONGO_MASTER, ENV_APPSERVER);
if (!is_object($mongoResource))
exit(gt() . ERROR_MONGO_CONNECT . COLON . RESOURCE_MONGO_MASTER . $eos);
// test to see if we can get a PDO master resource w/out explicitly re-declaring the resource manager singleton
$mysqlResource = gasResourceManager::fetchResource(RESOURCE_PDO_MASTER, ENV_APPSERVER);
if (!is_object($mysqlResource))
exit (gt() . ERROR_PDO_CONNECT . $eos);
// test to see if we can get a warehouse PDO resource w/out explicitly re-declaring the resource manager singleton
// (note: mongo warehouse resource not yet defined...)
$whCoolRes = gasResourceManager::fetchResource(RESOURCE_WH_COOL_PDO_MASTER, ENV_SEGUNDO);
if (!is_object($whCoolRes))
exit(gt() . ERROR_MONGO_CONNECT . COLON . RESOURCE_WH_COOL_PDO_MASTER . $eos);
// test to see if we can get a PDO slave resource w/out explicitly re-declaring the resource manager singleton
$PDOSlaveRes = gasResourceManager::fetchResource(RESOURCE_PDO_SECONDARY, ENV_APPSERVER);
if (!is_object($PDOSlaveRes))
exit(gt() . ERROR_PDO_CONNECT . COLON . RESOURCE_PDO_SECONDARY . $eos);
// test to see if we can get a broker resource w/out explicitly re-declaring the resource manager singleton
$broker = gasResourceManager::fetchResource(RESOURCE_BROKER, ENV_APPSERVER);
if (!is_object($broker))
exit(gt() . ERROR_BROKER_RESOURCE . $eos);
// test to see if we can get an admin broker resource w/out explicitly re-declaring the resource manager singleton
$broker = gasResourceManager::fetchResource(RESOURCE_ADMIN, ENV_APPSERVER);
if (!is_object($broker))
exit(gt() . ERROR_BROKER_RESOURCE . $eos);
// test to see if we can get a cache resource w/out explicitly re-declaring the resource manager singleton
$resCache = gasResourceManager::fetchResource(RESOURCE_CACHE, ENV_APPSERVER);
if (!is_object($resCache))
exit(gt() . ERROR_BROKER_RESOURCE . $eos);
// test to see if we can get a tercero mongo resource w/out explicitly re-declaring the resource manager singleton
$resTercero = gasResourceManager::fetchResource(RESOURCE_MONGO_MASTER, ENV_TERCERO);
if (!is_object($resTercero))
exit(gt() . ERROR_MONGO_CONNECT . COLON . RESOURCE_TERCERO . $eos);
exit(gt() . 'Lite resource testing successfully completed!' . $eos);