All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.contek.warlock.server.HeartbeatService Maven / Gradle / Ivy

There is a newer version: 1.2.2
Show newest version
package io.contek.warlock.server;

import io.contek.warlock.HeartbeatServiceGrpc.HeartbeatServiceImplBase;
import io.contek.warlock.SendHeartbeatRequest;
import io.contek.warlock.SendHeartbeatResponse;
import io.contek.warlock.server.beat.BeatManager;
import io.grpc.stub.StreamObserver;
import java.time.Duration;
import javax.annotation.concurrent.ThreadSafe;
import javax.inject.Inject;
import javax.inject.Singleton;

@ThreadSafe
@Singleton
final class HeartbeatService extends HeartbeatServiceImplBase {

  private final BeatManager cache;

  @Inject
  HeartbeatService(BeatManager cache) {
    this.cache = cache;
  }

  @Override
  public void sendHeartbeat(
      SendHeartbeatRequest request, StreamObserver observer) {
    cache.update(
        request.getAppName(),
        request.getTaskName(),
        Duration.ofSeconds(request.getTimeoutPeriod().getSeconds()));
    observer.onNext(SendHeartbeatResponse.newBuilder().build());
    observer.onCompleted();
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy