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.*;
9 import java.util.concurrent.ExecutionException;
13 @RequiredArgsConstructor
14 public class DriverController
16 private final EndlessConsumer consumer;
26 public void stop() throws ExecutionException, InterruptedException
33 public Map<Integer, Map<String, Map<String, Long>>> seen()
35 return consumer.getSeen();
38 @GetMapping("seen/{user}")
39 public ResponseEntity<Map<String, Long>> seen(@PathVariable String user)
41 for (Map<String, Map<String, Long>> users : consumer.getSeen().values())
43 Map<String, Long> words = users.get(user);
45 return ResponseEntity.ok(words);
48 return ResponseEntity.notFound().build();
53 @ResponseStatus(HttpStatus.BAD_REQUEST)
54 public ErrorResponse illegalStateException(IllegalStateException e)
56 return new ErrorResponse(e.getMessage(), HttpStatus.BAD_REQUEST.value());