@@ -4,14 +4,16 @@ import (
4
4
"context"
5
5
"encoding/json"
6
6
"fmt"
7
+ "net/http"
8
+ "time"
9
+
7
10
"github.com/feast-dev/feast/go/internal/feast"
8
11
"github.com/feast-dev/feast/go/internal/feast/model"
12
+ "github.com/feast-dev/feast/go/internal/feast/onlineserving"
9
13
"github.com/feast-dev/feast/go/internal/feast/server/logging"
10
14
"github.com/feast-dev/feast/go/protos/feast/serving"
11
15
prototypes "github.com/feast-dev/feast/go/protos/feast/types"
12
16
"github.com/feast-dev/feast/go/types"
13
- "net/http"
14
- "time"
15
17
)
16
18
17
19
type httpServer struct {
@@ -210,15 +212,15 @@ func (s *httpServer) getOnlineFeatures(w http.ResponseWriter, r *http.Request) {
210
212
"results" : results ,
211
213
}
212
214
215
+ w .Header ().Set ("Content-Type" , "application/json" )
216
+
213
217
err = json .NewEncoder (w ).Encode (response )
214
218
215
219
if err != nil {
216
220
http .Error (w , fmt .Sprintf ("Error encoding response: %+v" , err ), http .StatusInternalServerError )
217
221
return
218
222
}
219
223
220
- w .Header ().Set ("Content-Type" , "application/json" )
221
-
222
224
if featureService != nil && featureService .LoggingConfig != nil && s .loggingService != nil {
223
225
logger , err := s .loggingService .GetOrCreateLogger (featureService )
224
226
if err != nil {
@@ -250,18 +252,32 @@ func (s *httpServer) getOnlineFeatures(w http.ResponseWriter, r *http.Request) {
250
252
return
251
253
}
252
254
}
255
+ go releaseCGOMemory (featureVectors )
256
+ }
257
+
258
+ func releaseCGOMemory (featureVectors []* onlineserving.FeatureVector ) {
259
+ for _ , vector := range featureVectors {
260
+ vector .Values .Release ()
261
+ }
253
262
}
254
263
255
264
func (s * httpServer ) Serve (host string , port int ) error {
256
265
s .server = & http.Server {Addr : fmt .Sprintf ("%s:%d" , host , port ), Handler : nil }
257
266
http .HandleFunc ("/get-online-features" , s .getOnlineFeatures )
267
+ http .HandleFunc ("/health" , healthCheckHandler )
258
268
err := s .server .ListenAndServe ()
259
269
// Don't return the error if it's caused by graceful shutdown using Stop()
260
270
if err == http .ErrServerClosed {
261
271
return nil
262
272
}
263
273
return err
264
274
}
275
+
276
+ func healthCheckHandler (w http.ResponseWriter , r * http.Request ) {
277
+ w .WriteHeader (http .StatusOK )
278
+ fmt .Fprintf (w , "Healthy" )
279
+ }
280
+
265
281
func (s * httpServer ) Stop () error {
266
282
if s .server != nil {
267
283
return s .server .Shutdown (context .Background ())
0 commit comments