Class FileProbeManager

java.lang.Object
com.smeup.kokos.sdk.health.FileProbeManager

public final class FileProbeManager extends Object
File-based liveness/readiness probe for services that don't expose an HTTP API (e.g. observer-manager). Periodically mirrors a HealthState onto the filesystem: the file is (re)written while healthy and deleted otherwise, so an external prober (e.g. a container exec probe or livenessProbe.exec) just needs to check for the file's existence/freshness — no port to expose.

Usage


 HealthState health = new HealthState(true, false);

 FileProbeManager.startPeriodicProbeTask(health);   // uses /tmp/live and /tmp/ready

 EventConsumerStartupContext<MyEvent> ctx = new EventConsumerStartupContext<>(...);
 ctx.setHealthState(health);
 EventConsumer.startConsumerWithRetry(ctx);
 

Container probe example (exec-based, e.g. Kubernetes or Docker HEALTH CHECK):


 livenessProbe:
   exec:
     command: ["test", "-f", "/tmp/live"]
 readinessProbe:
   exec:
     command: ["test", "-f", "/tmp/ready"]
 
  • Method Details

    • startPeriodicProbeTask

      public static void startPeriodicProbeTask()
      Starts the probe task using HealthState.global() and default files/interval.
    • startPeriodicProbeTask

      public static void startPeriodicProbeTask(HealthState healthState)
      Starts the probe task for the given HealthState, using default files (/tmp/live, /tmp/ready) and a 5s interval.
    • startPeriodicProbeTask

      public static void startPeriodicProbeTask(HealthState healthState, Path liveFile, Path readyFile, long intervalSeconds)
      Starts the probe task, writing/deleting liveFile and readyFile every intervalSeconds according to healthState.
      Parameters:
      healthState - shared health state to mirror onto disk
      liveFile - path touched while HealthState.isLive() is true, deleted otherwise
      readyFile - path touched while HealthState.isReady() is true, deleted otherwise
      intervalSeconds - polling interval in seconds
    • stopPeriodicProbeTask

      public static void stopPeriodicProbeTask()
      Stops the probe task; the last written/deleted files are left as-is.