Skip to content

Commit

Permalink
Merge pull request #37 from ExpediaGroup/go_server_status
Browse files Browse the repository at this point in the history
feat: Adding option to omit status response from go feature server response
  • Loading branch information
omirandadev authored Sep 27, 2023
2 parents 76d265e + 91f8be2 commit 6cf454c
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions go/internal/feast/server/http_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"net/http"
"os"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -148,6 +149,17 @@ func (s *httpServer) getOnlineFeatures(w http.ResponseWriter, r *http.Request) {
return
}

statusQuery := r.URL.Query().Get("status")
status := false
if statusQuery != "" {
var err error
status, err = strconv.ParseBool(statusQuery)
if err != nil {
http.Error(w, fmt.Sprintf("Error parsing status query parameter: %+v", err), http.StatusBadRequest)
return
}
}

decoder := json.NewDecoder(r.Body)
var request getOnlineFeaturesRequest
err := decoder.Decode(&request)
Expand Down Expand Up @@ -190,17 +202,19 @@ func (s *httpServer) getOnlineFeatures(w http.ResponseWriter, r *http.Request) {
for _, vector := range featureVectors {
featureNames = append(featureNames, vector.Name)
result := make(map[string]interface{})
var statuses []string
for _, status := range vector.Statuses {
statuses = append(statuses, status.String())
}
var timestamps []string
for _, timestamp := range vector.Timestamps {
timestamps = append(timestamps, timestamp.AsTime().Format(time.RFC3339))
}
if status {
var statuses []string
for _, status := range vector.Statuses {
statuses = append(statuses, status.String())
}
var timestamps []string
for _, timestamp := range vector.Timestamps {
timestamps = append(timestamps, timestamp.AsTime().Format(time.RFC3339))
}

result["statuses"] = statuses
result["event_timestamps"] = timestamps
result["statuses"] = statuses
result["event_timestamps"] = timestamps
}
// Note, that vector.Values is an Arrow Array, but this type implements JSON Marshaller.
// So, it's not necessary to pre-process it in any way.
result["values"] = vector.Values
Expand Down

0 comments on commit 6cf454c

Please sign in to comment.