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:
57
stubs/testCONS.php
Normal file
57
stubs/testCONS.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
// load the namaste environment
|
||||
require_once(dirname(__DIR__) . '/config/sneakerstrap.inc');
|
||||
$errors = [];
|
||||
/** @var gacMongoDB $widget */
|
||||
$widget = null;
|
||||
$lastUpdated = '';
|
||||
$recordCount = 0;
|
||||
|
||||
# build meta data payload
|
||||
$meta = [
|
||||
META_TEMPLATE => TEMPLATE_CLASS_CSL,
|
||||
META_CLIENT => CLIENT_SYSTEM,
|
||||
META_EVENT_GUID => guid(),
|
||||
META_LIMIT_OVERRIDE => 1, // turn off record processing limit
|
||||
META_DO_CACHE => 0
|
||||
];
|
||||
|
||||
# instantiate the template via the factory class:
|
||||
$widget = grabWidget($meta, '', $errors);
|
||||
|
||||
// read the xml file into memory to build a simulated broker payload
|
||||
$file = DIR_TMP . SLASH . 'consolidated.xml';
|
||||
if (!file_exists($file))
|
||||
exit (ERROR_FILE_404 . $file . PHP_EOL);
|
||||
elseif (false === ($contents = file_get_contents($file)))
|
||||
exit(ERROR_OPEN_XML_FILE . $file);
|
||||
$payload = [
|
||||
BROKER_REQUEST => BROKER_REQUEST_CONS,
|
||||
BROKER_DATA => [STRING_DATA => $contents],
|
||||
META_DATA => $meta
|
||||
];
|
||||
if (is_null($newFileName = $widget->template->saveCONSList($payload[BROKER_DATA], $errors)))
|
||||
exit(ERROR_SAVE_XML_FILE . DIR_TMP . PHP_EOL);
|
||||
|
||||
if (is_null($aryData = $widget->template->processCONSList($newFileName, $errors, $lastUpdated, $recordCount)))
|
||||
exit(ERROR_DATA_PROCESSING . PHP_EOL);
|
||||
|
||||
// b/c we're dealing with non-broker-submitted data, force a cache-mapping onto the data payload
|
||||
if (is_null($aryData = gasCache::buildMappedDataArray($aryData, $widget->cacheMap, $widget->ext)))
|
||||
exit(ERROR_CACHE_MAP_FAIL . $widget->class);
|
||||
|
||||
//$widget->addData($aryData);
|
||||
|
||||
$widget->_createRecord($aryData, DATA_CONS);
|
||||
if (!$widget->status) {
|
||||
var_export($widget->eventMessages);
|
||||
exit ('Processing failed' . PHP_EOL);
|
||||
} elseif ($widget->count != $recordCount) {
|
||||
exit(sprintf(ERROR_DATA_RECORD_COUNT, $recordCount, $widget->count));
|
||||
}
|
||||
|
||||
// unlink the guid-file from tmp and save the original file in the system table
|
||||
$widget->template->cleanup($newFileName);
|
||||
|
||||
echo $recordCount . ' records successfully upserted to CONS table' . PHP_EOL;
|
||||
exit('Processing successful' . PHP_EOL);
|
||||
Reference in New Issue
Block a user