tag:robotlegs.tenderapp.com,2009-10-18:/discussions/robotlegs-2/17647-command-retriesRobotlegs: Discussion 2016-11-12T15:22:38Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/412012082016-11-10T18:31:46Z2016-11-10T18:31:46ZCommand retries<div><p>Is there a way currently to set up a command so that it will
have a number of retry attempts before actually being marked as
failed?</p>
<p>I am thinking about implementing something like that but didn't
know if someone else might have already written a plugin or
not.</p>
<p>map.mapCommand().toCommand().maxRetries();</p></div>kamcknigtag:robotlegs.tenderapp.com,2009-10-18:Comment/412012082016-11-11T13:47:38Z2016-11-11T13:47:38ZCommand retries<div><p>Hi :)</p>
<p>I'm not sure I understand what you want to achieve, but maybe
guards and hooks are the answer to your problem. Have you tried to
use them already?</p>
<p>Command mapping with guards and hooks:</p>
<p><a href="https://github.com/robotlegs/robotlegs-framework/tree/master/src/robotlegs/bender/extensions/eventCommandMap#mapping-guards-and-hooks">
https://github.com/robotlegs/robotlegs-framework/tree/master/src/ro...</a></p>
<p>Guards:</p>
<p><a href="https://github.com/robotlegs/robotlegs-framework/blob/master/src/robotlegs/bender/framework/readme-guards.md">
https://github.com/robotlegs/robotlegs-framework/blob/master/src/ro...</a></p>
<p>Hooks:</p>
<p><a href="https://github.com/robotlegs/robotlegs-framework/blob/master/src/robotlegs/bender/framework/readme-hooks.md">
https://github.com/robotlegs/robotlegs-framework/blob/master/src/ro...</a></p>
<p>There are also a few discussion about guards and hooks.</p>
<p>The macrobot utility is also interesting:<br>
<a href="https://github.com/alebianco/robotlegs-utilities-macrobot">https://github.com/alebianco/robotlegs-utilities-macrobot</a></p>
<blockquote>
<p>I am thinking about implementing something like that but didn't
know if someone else might have already written a plugin or
not.</p>
</blockquote>
<p>Not to my knowledge.</p>
<p>Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/412012082016-11-11T14:00:50Z2016-11-11T14:00:50ZCommand retries<div><p>Yes I have, so what I am doing is using the macro utilties
plugin to run a sequence macro that consists of three commands</p>
<pre>
<code>prepare()
{
add(CommandOne);
add(CommandTwo);
add(CommandThree);
}</code>
</pre>
<p>I want the macro to succeed only if all three commands succeed.
Each command is an AsyncCommand. Now, what I want to do is if let's
say CommandTwo fails (maybe it can't retrieve data from the server)
then I'd like it to retry CommandTwo up to X amount of times before
it says the macro command fails or succeeds. I know I can control
this within CommandTwo by writring my own code to retry it and only
dispatchComplete() when I want, but I didn't know if there was an
automated way already set upo so that I could write something
like</p>
<pre>
<code>prepare()
{
add(CommandOne);
add(CommandTwo).maxRetries(3);
add(CommandThree);
}</code>
</pre>
<p>So that CommandTwo will be retried in the robotlegs2 framework
automatically without me writing that code.</p>
<p>Does that make sense?</p></div>kamcknigtag:robotlegs.tenderapp.com,2009-10-18:Comment/412012082016-11-11T16:47:52Z2016-11-11T16:47:52ZCommand retries<div><p>Yes, I understand now.</p>
<p>Robotlegs can't do it automatically.</p>
<p>I think, what you want is to perform the action inside of a
command n times, not to trigger the command itself n times,
right?<br>
Make a base command having the retry logic and extend it wherever
you need.</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/412012082016-11-11T17:08:16Z2016-11-11T17:08:16ZCommand retries<div><p>Correct, that's what I'm currently doing. But was thinking about
trying to modify the framework to allow for it automatically if
possible. But either way, question answered! Thanks</p></div>kamcknigtag:robotlegs.tenderapp.com,2009-10-18:Comment/412012082016-11-12T15:22:37Z2016-11-12T15:22:37ZCommand retries<div><p>You're welcome!</p></div>Ondina D.F.