craigcondit commented on code in PR #589:
URL: https://github.com/apache/yunikorn-core/pull/589#discussion_r1270804870


##########
pkg/webservice/handlers.go:
##########
@@ -869,3 +870,53 @@ func getGroupResourceUsage(w http.ResponseWriter, r 
*http.Request) {
                buildJSONErrorResponse(w, err.Error(), 
http.StatusInternalServerError)
        }
 }
+
+func getEvents(w http.ResponseWriter, r *http.Request) {
+       writeHeaders(w)
+       eventSystem := events.GetEventSystem()
+       if eventSystem == nil {
+               buildJSONErrorResponse(w, "Event system is disabled", 
http.StatusBadRequest)
+               return
+       }
+
+       count := uint64(10000)
+       var fromId uint64
+       vars := httprouter.ParamsFromContext(r.Context())
+       if vars != nil {
+               if countStr := vars.ByName("count"); countStr != "" {
+                       c, err := strconv.ParseInt(countStr, 10, 64)
+                       if err != nil {
+                               buildJSONErrorResponse(w, err.Error(), 
http.StatusBadRequest)
+                               return
+                       }
+                       if c <= 0 {
+                               buildJSONErrorResponse(w, fmt.Sprintf("Illegal 
number of events: %d", c), http.StatusBadRequest)
+                               return
+                       }
+                       count = uint64(c)
+               }
+
+               if fromIdStr := vars.ByName("fromId"); fromIdStr != "" {
+                       i, err := strconv.ParseInt(fromIdStr, 10, 64)
+                       if err != nil {
+                               buildJSONErrorResponse(w, err.Error(), 
http.StatusBadRequest)
+                               return
+                       }
+                       if i < 0 {
+                               buildJSONErrorResponse(w, fmt.Sprintf("Illegal 
id: %d", i), http.StatusBadRequest)
+                               return
+                       }
+                       fromId = uint64(i)
+               }
+       }
+
+       records, lowestId, highestID := eventSystem.GetEventsFromId(fromId, 
count)

Review Comment:
   Nit: use lowestID to match highestID.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to