@@ -4,14 +4,16 @@ import (
44 "context"
55 "encoding/json"
66 "fmt"
7+ "net/http"
8+ "time"
9+
710 "github.com/feast-dev/feast/go/internal/feast"
811 "github.com/feast-dev/feast/go/internal/feast/model"
12+ "github.com/feast-dev/feast/go/internal/feast/onlineserving"
913 "github.com/feast-dev/feast/go/internal/feast/server/logging"
1014 "github.com/feast-dev/feast/go/protos/feast/serving"
1115 prototypes "github.com/feast-dev/feast/go/protos/feast/types"
1216 "github.com/feast-dev/feast/go/types"
13- "net/http"
14- "time"
1517)
1618
1719type httpServer struct {
@@ -210,15 +212,15 @@ func (s *httpServer) getOnlineFeatures(w http.ResponseWriter, r *http.Request) {
210212 "results" : results ,
211213 }
212214
215+ w .Header ().Set ("Content-Type" , "application/json" )
216+
213217 err = json .NewEncoder (w ).Encode (response )
214218
215219 if err != nil {
216220 http .Error (w , fmt .Sprintf ("Error encoding response: %+v" , err ), http .StatusInternalServerError )
217221 return
218222 }
219223
220- w .Header ().Set ("Content-Type" , "application/json" )
221-
222224 if featureService != nil && featureService .LoggingConfig != nil && s .loggingService != nil {
223225 logger , err := s .loggingService .GetOrCreateLogger (featureService )
224226 if err != nil {
@@ -250,18 +252,32 @@ func (s *httpServer) getOnlineFeatures(w http.ResponseWriter, r *http.Request) {
250252 return
251253 }
252254 }
255+ go releaseCGOMemory (featureVectors )
256+ }
257+
258+ func releaseCGOMemory (featureVectors []* onlineserving.FeatureVector ) {
259+ for _ , vector := range featureVectors {
260+ vector .Values .Release ()
261+ }
253262}
254263
255264func (s * httpServer ) Serve (host string , port int ) error {
256265 s .server = & http.Server {Addr : fmt .Sprintf ("%s:%d" , host , port ), Handler : nil }
257266 http .HandleFunc ("/get-online-features" , s .getOnlineFeatures )
267+ http .HandleFunc ("/health" , healthCheckHandler )
258268 err := s .server .ListenAndServe ()
259269 // Don't return the error if it's caused by graceful shutdown using Stop()
260270 if err == http .ErrServerClosed {
261271 return nil
262272 }
263273 return err
264274}
275+
276+ func healthCheckHandler (w http.ResponseWriter , r * http.Request ) {
277+ w .WriteHeader (http .StatusOK )
278+ fmt .Fprintf (w , "Healthy" )
279+ }
280+
265281func (s * httpServer ) Stop () error {
266282 if s .server != nil {
267283 return s .server .Shutdown (context .Background ())
0 commit comments