ilya-kozyrev commented on a change in pull request #16277:
URL: https://github.com/apache/beam/pull/16277#discussion_r772381746
##########
File path: playground/backend/internal/environment/environment_service.go
##########
@@ -137,6 +140,17 @@ func GetNetworkEnvsFromOsEnvs() (*NetworkEnvs, error) {
func ConfigureBeamEnvs(workDir string) (*BeamEnvs, error) {
sdk := pb.Sdk_SDK_UNSPECIFIED
preparedModDir, modDirExist := os.LookupEnv(preparedModDirKey)
+
+ numOfParallelJobs := defaultNumOfParallelJobs
+ if value, present := os.LookupEnv(numOfParallelJobsKey); present {
+ convertedValue, err := strconv.Atoi(value)
+ if err != nil {
+ logger.Errorf("Incorrect value for %s. Should be
integer. Will be used default value: %d", numOfParallelJobsKey,
defaultNumOfParallelJobs)
Review comment:
I think we can't run the server without this variable, at least it
should return this error.
##########
File path: playground/backend/cmd/server/http.go
##########
@@ -19,12 +19,28 @@ import (
"beam.apache.org/playground/backend/internal/logger"
"context"
"net/http"
+ "os"
+ "path/filepath"
)
// listenHttp binds the http.Handler on the TCP network address
-func listenHttp(ctx context.Context, errChan chan error, envs
environment.NetworkEnvs, handler http.Handler) {
- logger.Infof("listening HTTP at %s\n", envs.Address())
- if err := http.ListenAndServe(envs.Address(), handler); err != nil {
+func listenHttp(ctx context.Context, errChan chan error, envs
*environment.Environment, handler http.Handler) {
+ address := envs.NetworkEnvs.Address()
+ logger.Infof("listening HTTP at %s\n", address)
+
+ mux := http.NewServeMux()
+ mux.Handle("/", handler)
+ mux.HandleFunc("/readiness", func(w http.ResponseWriter, r
*http.Request) {
Review comment:
Could you please extract the function to logical block?
##########
File path: playground/backend/cmd/server/http.go
##########
@@ -33,3 +49,28 @@ func listenHttp(ctx context.Context, errChan chan error,
envs environment.Networ
return
}
}
+
+// isReady checks the number of already working code processing.
+// It counts by the number of the
/path/to/workingDir/executable_files/{pipelineId} folders.
+// If it is equals or more than numOfParallelJobs, then returns false.
+// If it is less than numOfParallelJobs, then returns true.
+func isReady(workingDir string, numOfParallelJobs int) bool {
Review comment:
I believe that server/http not a best place for business logic
--
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]