package de.juplo.kafka;
import lombok.RequiredArgsConstructor;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.*;
+import java.util.Map;
import java.util.concurrent.ExecutionException;
public class DriverController
{
private final EndlessConsumer consumer;
+ private final ApplicationRecordHandler recordHandler;
@PostMapping("start")
{
consumer.stop();
}
+
+
+ @GetMapping("state")
+ public Map<Integer, Map<String, Long>> state()
+ {
+ return recordHandler.getState();
+ }
+
+
+ @ExceptionHandler
+ @ResponseStatus(HttpStatus.BAD_REQUEST)
+ public ErrorResponse illegalStateException(IllegalStateException e)
+ {
+ return new ErrorResponse(e.getMessage(), HttpStatus.BAD_REQUEST.value());
+ }
}