From db3089525f8452c55a5f4a0c19b4dd30f4be3459 Mon Sep 17 00:00:00 2001 From: Timothy Ehlers Date: Thu, 21 Nov 2024 21:43:35 -0600 Subject: [PATCH] add grpc+http concurrent serving --- go/main.go | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/go/main.go b/go/main.go index 97f7d486c2..4c9e67abaa 100644 --- a/go/main.go +++ b/go/main.go @@ -45,21 +45,22 @@ func (s *RealServerStarter) StartGrpcServer(fs *feast.FeatureStore, host string, func main() { // Default values - serverType := "http" host := "" port := 8080 - server := RealServerStarter{} + grpcPort := 6565 + rServer := RealServerStarter{} + gServer := RealServerStarter{} // Current Directory repoPath, err := os.Getwd() if err != nil { log.Error().Stack().Err(err).Msg("Failed to get current directory") } - flag.StringVar(&serverType, "type", serverType, "Specify the server type (http or grpc)") flag.StringVar(&repoPath, "chdir", repoPath, "Repository path where feature store yaml file is stored") flag.StringVar(&host, "host", host, "Specify a host for the server") - flag.IntVar(&port, "port", port, "Specify a port for the server") + flag.IntVar(&port, "port", port, "Specify a rest port for the server") + flag.IntVar(&grpcPort, "grpcPort", grpcPort, "Specify a grpc port for the server") flag.Parse() repoConfig, err := registry.NewRepoConfigFromFile(repoPath) @@ -77,19 +78,18 @@ func main() { log.Fatal().Stack().Err(err).Msg("Failed to get LoggingOptions") } - // TODO: writeLoggedFeaturesCallback is defaulted to nil. write_logged_features functionality needs to be - // implemented in Golang specific to OfflineStoreSink. Python Feature Server doesn't support this. - if serverType == "http" { - err = server.StartHttpServer(fs, host, port, nil, loggingOptions) - } else if serverType == "grpc" { - err = server.StartGrpcServer(fs, host, port, nil, loggingOptions) - } else { - fmt.Println("Unknown server type. Please specify 'http' or 'grpc'.") - } - - if err != nil { - log.Fatal().Stack().Err(err).Msg("Failed to start server") - } + go func() { + err := rServer.StartHttpServer(fs, host, port, nil, loggingOptions) + if err != nil { + log.Fatal().Stack().Err(err).Msg("Failed to start server") + } + }() + go func() { + err := gServer.StartGrpcServer(fs, host, grpcPort, nil, loggingOptions) + if err != nil { + log.Fatal().Stack().Err(err).Msg("Failed to start server") + } + }() }