Hi,

although in general I like fluent APIs, in this case IMHO there is not really a point in creating one. The HealthCheckExecutor is only to be used by JMX and the web console (and maybe at some point by some servlet), but not as part of a normal implementation project. However, I think projects will implement their own health checks, but rarely have the need to execute them in a custom fashion if JMX and the web console are configurable in a flexible way. It is really like Servlets: You implement the interface and make them known to the container, but you don't ever run them yourself from java (as the container does this for you).

-Georg

Am 19.12.2013 11:21, schrieb Bertrand Delacretaz:
Hi,

I thought a bit more about the SLING-3278 HealthCheckExecutor service,
and a fluent interface might be useful:

interface HealthCheckExecutor {
 /** Select all HealthChecks for execution */
 HealthCheckContext all();

 /** Select a single HealthCheck for execution */
 HealthCheckContext for(HealthCheck hc);

 /** Select HealthChecks by tag for execution */
HealthCheckContext forTags(String ...tags);
}

/** Context holds execution options and triggers the actual execution */
interface HealthCheckContext {
  void withTimeout(int timeout, TimeUnits units);
  void clearCache();
  AggregatedResult getResult();
  List<Result> getAllResults();
}

Which allows for writing things like

  executor.all().getAllResults();
  executor.for(hc).getResult();

  executor
    .forTags("foo", "-bar")
    .withTimeout(5, TimeUnit.SECONDS)
    .getResult();

  // Clear cache before execution
  executor.forTags("security").clearCache().getAllResults();

  // Clear all cached Results
  executor.all().clearCache();

AggregatedResult extends Result with a List<Result> getResults()
method. Its status is the highest of the aggregated statuses, and its
log is the concatenation of all individual logs.

WDYT?
-Bertrand

Reply via email to