kiwiproject / kiwi

A set of Java utilities that we could not find in Guava or Apache Commons...or we just felt like having our own version.
MIT License
12 stars 1 forks source link

Add method in KiwiDropwizardLifecycles to manage and only provide a stop action #1163

Closed sleberknight closed 3 months ago

sleberknight commented 4 months ago

KiwiDropwizardLifecycles contains one method, manage, which lets you provide both a startAction and a stopAction.

Many times, for example when using a Jakarta REST Client or a RegistryAwareClient, you only need the stopAction.

In those cases you still must provide a startAction even when it is a no-op. We have a bunch of these in various services, and they all pass Guava's Runnables#doNothing() as the argument. It would be nice not to have to do this and remove the boilerplate.

This issue proposes to add a new method (or two) that allows you to provide a start action, or maybe two methods for the opposite case, to only perform a start action.

Possible method signatures:

The implementations of these are trivial, since they will simply use Runnables#doNothing() for the action they don't care about. But, they make it more clear what is happening, i.e., "we only need to manage when this thing stops".