952 days continuous production uptime, 40k+ tp/s single node. Original corpo Bitbucket history not included — clean archive commit.
71 lines
2.4 KiB
PHP
71 lines
2.4 KiB
PHP
<?php
|
|
/**
|
|
* CORE-1000 -- stubby little script to test-out namaste's remote fetch ability.
|
|
*
|
|
* @author mike@givingassistant.org
|
|
* @version 1.0
|
|
*
|
|
* HISTORY:
|
|
* ========
|
|
* 06-07-18 mks CORE-1000: initial coding
|
|
*
|
|
*/
|
|
|
|
// load the namaste environment
|
|
require_once(dirname(__DIR__) . '/config/sneakerstrap.inc');
|
|
const OBJECT = 1;
|
|
const BROKER = 2;
|
|
|
|
$res = '_TRF: '; // test remote fetch
|
|
|
|
// if processing is OBJECT, we can use the debugger
|
|
// if processing is BROKER, event is passed to migration broker
|
|
$processing = OBJECT;
|
|
|
|
// set up the data payloads
|
|
$meta = [
|
|
META_CLIENT => CLIENT_SYSTEM, // back-door the meta-data checks
|
|
// this is a meta-record so this request will go to the admin service
|
|
META_TEMPLATE => TEMPLATE_CLASS_WAREHOUSE, // choose a template that's not local to appServer
|
|
// this template is for a warehouse record so the request will go to segundo service
|
|
META_TEMPLATE => TEMPLATE_CLASS_WHC1_PROD_REG,
|
|
META_CLIENT_IP => STRING_SESSION_HOME, // required
|
|
META_EVENT_GUID => guid() // simulate a broker event by generating the event guid
|
|
];
|
|
|
|
// warehouse meta data (admin)
|
|
$data = [
|
|
STRING_QUERY_DATA => [ DB_TOKEN => [OPERAND_NULL => [OPERATOR_EQ => ['96811337-85F1-A274-8557-F8312B757D74']]]]
|
|
];
|
|
|
|
// warehouse actual data (segundo)
|
|
$data = [
|
|
STRING_QUERY_DATA => [ DB_WH_TOKEN => [OPERAND_NULL => [OPERATOR_EQ => ['8C87E8E9-33E4-42A6-59FA-741711453DFF']]]]
|
|
];
|
|
|
|
// This request event is only available in the namaste (appServer) read broker. However, the data (template) defines
|
|
// the segundo service...which has an event called BROKER_REQUEST_REMOTE_FETCH. This event will be called, on behalf
|
|
// of the client, by the read-broker...
|
|
$request = BROKER_REQUEST_FETCH;
|
|
|
|
$request = [
|
|
BROKER_REQUEST => $request,
|
|
BROKER_DATA => $data,
|
|
BROKER_META_DATA => $meta
|
|
];
|
|
$payload = gzcompress(json_encode($request));
|
|
|
|
$brokerClient = new gacBrokerClient(BROKER_QUEUE_R, __METHOD__ . AT . __LINE__);
|
|
if (!$brokerClient->status) {
|
|
consoleLog($res, CON_ERROR, ERROR_BROKER_CLIENT_DECLARE . BROKER_QUEUE_R);
|
|
|
|
} else {
|
|
$response = $brokerClient->call($payload);
|
|
$response = json_decode(gzuncompress($response), true);
|
|
|
|
var_export($response);
|
|
}
|
|
if (is_object($brokerClient)) $brokerClient->__destruct();
|
|
unset($brokerClient);
|
|
echo $eos . 'Program ends...' . $eos;
|