lr_end_transaction_instance example

long id;
int status;

/* Call to server API */
int amount_overdrawn = get_amount_overdrawn();
while (amount_overdrawn < LIMIT) {
/* Notify that a transaction is starting */
    id = lr_start_transaction("withdraw");

/* Call to server API */
    status = bank_withdraw(500);

/* End transaction with operation result - pass or fail */
    if (status == 0)
        lr_end_transaction("withdraw"LR_PASS);
    else
        lr_end_transaction("withdraw"LR_FAIL);
   
    amount_overdrawn = get_amount_overdrawn();
}
/* The client is unable to withdraw anymore as the overdraft limit has been reached. Try to withdraw anyway to record the server response time */
    id = lr_start_transaction_instance("withdraw"0);

/* This call will fail, but we want to time it */
    status = bank_withdraw(500);
    lr_end_transaction_instance(id, LR_PASS);

No comments:

Post a Comment