Paul Sullivan

Paul Sullivan

GO!

Project Scope

Large legacy LAMP environment in the FX sector little to no handover, 2 months in to the contract.  There was a need to have up-to-the-second balance information for clients, with these complications:

  1. Balances in at least 2 perhaps up to 30 currencies simultaneously
  2. There was no journal/ledger system in place so calculations needed to take into account Txns from all time for each ReCalc
  3. There was no one point in the PHP application where every Txn type that could change a balance would pass though (around 5 classes and 70 programs).
  4. There were only 2 tables in the SQL DB where every Txn type that could change a client's balance would pass through.

The code to calculate already existed (in PHP).

Method

In the end it went some thing like this:

  1. MySQL Trigger called a Proc
    TriggerStatementCalcFromDealID(NEW.id,'bo_deals_after_upd_tr');
  2. The Proc used sys_exec to call a bash script passing args on the CLI
    select sys_exec(concat("/APPLIVEv3/SHELL/statement.calc.sh ",accountnoX," TriggerStatementCalcFromDealID/",triggerX,"/",dealid)) into tmpX;
  3. This then used wget to call the PHP event
    wget $BOHTTPPATH../ot/statement.calc.php?accountno=$1 -O - 2> /dev/null &

The end result solved the problem and the additional issue of latency in the PHP app.  This system has now been running largely unchanged for over 3 years.

Valid XHTML 1.1 Strict Valid CSS

Originally from East London in South Africa. I recently moved to Dorking, Surrey having previously lived in the London Borough of Sutton and Cape Town