creaper icon indicating copy to clipboard operation
creaper copied to clipboard

Remove commands should optionaly remove resources lazily

Open zebrik opened this issue 8 years ago • 11 comments

Since these commands are often used just for cleaning up after tests the lazy remove could be valid use case and the commands should be able to be configured to behave lazily.

zebrik avatar Jun 15 '16 12:06 zebrik

Hmm, now that's an interesting idea. We could change all command implementations, and make sure that we don't miss anything in the future. That's not gonna work. Or there could be some global configuration -- I honestly don't like that idea very much, but it also makes a lot of sense (one of Creaper's goals is to help with testing). I'll have to think about that. Or you can provide some highly compelling arguments :-)

BTW the correct word here wouldn't be "lazy" but "lenient". "Lazy" is already used in Creaper in a different context and with a different meaning.

Ladicek avatar Jun 15 '16 12:06 Ladicek

Rather than guaranteed feature I meant common (recommended ?) way how to implement removing commands. See https://github.com/wildfly-extras/creaper/pull/117 discussion.

zebrik avatar Jun 15 '16 13:06 zebrik

I meant this issue as a suggestion how to enhance (some) existing commands and how to review upcoming ones.

zebrik avatar Jun 15 '16 13:06 zebrik

OK, so we already have a similar convention: builders of the Add* commands often have a replaceExisting() method.

I'd suggest that builders of the Remove* commands would have a method called lenient() or onlyIfExists() or ignoreMissing() or something like that. Then, based on such flag, the command would either call Operations.remove or Operations.removeIfExists.

Would you agree with such solution?

Ladicek avatar Jun 15 '16 13:06 Ladicek

I actually like ignoreMissing() the most, because it's symmetric with replaceExisting().

Ladicek avatar Jun 15 '16 13:06 Ladicek

+1 I suggest ifExists()

zebrik avatar Jun 15 '16 13:06 zebrik

no problem with ignoreMissing()

zebrik avatar Jun 15 '16 13:06 zebrik

Many Remove* commands don't use builders ATM. Thus we will need to maintain two constructors, one based on Builder and the current one in order to not break API.

Just saying. I am definitely for such option, I would find it handy as well.

rhatlapa avatar Jun 15 '16 13:06 rhatlapa

I'd prefer adding builders for options like this. The existing constructors would have to be preserved, of course.

Ladicek avatar Jun 15 '16 13:06 Ladicek

I am also for builders for such options, I just wanted to point out the need for preserving current constructors.

rhatlapa avatar Jun 15 '16 13:06 rhatlapa

Then we are in agreement and the only remaining thing is to find someone who will do it :-)

Ladicek avatar Jun 15 '16 13:06 Ladicek