package com.outbrain.ob1k.consul;

import com.outbrain.ob1k.Service;
import com.outbrain.ob1k.concurrent.ComposableFuture;

import java.util.List;

/**
 * A programmatic API that maps to the /v1/health/* consul REST API
 *
 * @author Eran Harel
 */
public interface ConsulHealth extends Service {

  ComposableFuture<List<HealthInfoInstance>> filterDcLocalHealthyInstances(final String service, final String filterTag);

  ComposableFuture<List<HealthInfoInstance>> pollHealthyInstances(final String service, final String filterTag, final long index);

  ComposableFuture<List<HealthInfoInstance>> getInstancesHealth(final String service, final String dc);

  ComposableFuture<List<HealthInfoInstance.Check>> getInstancesChecks(final String service, final String dc);

  ComposableFuture<List<HealthInfoInstance.Check>> getInstancesAtState(final States state, final String dc);

  enum States {
    ANY,
    UNKNOWN,
    PASSING,
    WARNING,
    CRITICAL;

    @Override
    public String toString() {
      return name().toLowerCase();
    }
  }
}
@@ -115,16 +115,61 @@
 eFuture;
+%0Aimport com.outbrain.ob1k.http.TypedResponse;
 %0A%0Aimport
@@ -470,32 +470,46 @@
 omposableFuture%3C
+TypedResponse%3C
 List%3CHealthInfoI
@@ -517,16 +517,17 @@
 stance%3E%3E
+%3E
  pollHea

Allow using consul index from a single response when polling for health