PHP Library for implementing transaction aware api calls? -
to implement few of functionalities, need call set of apis in order. there times when 1 of apis in middle fail. @ such times need rollback api calls have happened before that. command / function queue transaction rollback support.
also there times when need inject result of 1 of function calls parameter later function call. nice if there protocol that.
what know if has come across such (php) library or if there elegant way implement this, state machine maybe? or talking gibberish!!
obviously, there quite few nuances considered, happens if rollback fails, etc..
i call library below:
// first command $cmd1 = new \transaction\command("command one") ->setfunction( function () { echo "running command one"; return "one"; } ) ->setrollback( function () { return "rolled command one"; } ); // second command $cmd2 = new \transaction\command("command two") ->setfunction( function ($resultfromcmdone) { echo "running command 2 with". " result command one: $resultfromcmdone"; return "two"; } ) ->setrollback( function () { return "rolled command two"; } ); $cmdqueue = new \native5\transaction\commandqueue(); $cmdqueue->addcommand($cmd1); $cmdqueue->addcommand($cmd2); // process set of commands $cmdqueue->process();
Comments
Post a Comment