1 package de.juplo.kafka;
3 import lombok.RequiredArgsConstructor;
4 import org.springframework.http.HttpStatus;
5 import org.springframework.http.ResponseEntity;
6 import org.springframework.web.bind.annotation.*;
10 import java.util.concurrent.ExecutionException;
14 @RequiredArgsConstructor
15 public class DriverController
17 private final EndlessConsumer consumer;
18 private final SumRecordHandler sumRecordHandler;
28 public void stop() throws ExecutionException, InterruptedException
35 public Map<Integer, Map<String, List<Long>>> seen()
37 return sumRecordHandler.getSeen();
40 @GetMapping("seen/{user}")
41 public ResponseEntity<List<Long>> seen(@PathVariable String user)
43 for (Map<String, List<Long>> users : sumRecordHandler.getSeen().values())
45 List<Long> results = users.get(user);
47 return ResponseEntity.ok(results);
50 return ResponseEntity.notFound().build();
55 @ResponseStatus(HttpStatus.BAD_REQUEST)
56 public ErrorResponse illegalStateException(IllegalStateException e)
58 return new ErrorResponse(e.getMessage(), HttpStatus.BAD_REQUEST.value());