AydarZaynutdinov commented on a change in pull request #16277:
URL: https://github.com/apache/beam/pull/16277#discussion_r774482879



##########
File path: playground/backend/internal/utils/system_utils.go
##########
@@ -16,14 +16,59 @@
 package utils
 
 import (
+       "beam.apache.org/playground/backend/internal/environment"
+       "beam.apache.org/playground/backend/internal/logger"
+       "net/http"
+       "os"
+       "path/filepath"
        "reflect"
        "runtime"
        "strings"
 )
 
+const (
+       executableFiles = "executable_files"
+)
+
 // GetFuncName returns the name of the received func
 func GetFuncName(i interface{}) string {
        fullName := runtime.FuncForPC(reflect.ValueOf(i).Pointer()).Name()
        splitName := strings.Split(fullName, ".")
        return splitName[len(splitName)-1]
 }
+
+// GetReadinessFunction returns the function that checks the readiness of the 
server to process a new code processing request
+func GetReadinessFunction(envs *environment.Environment) func(writer 
http.ResponseWriter, request *http.Request) {
+       return func(writer http.ResponseWriter, request *http.Request) {
+               if checkNumOfTheParallelJobs(envs.ApplicationEnvs.WorkingDir(), 
envs.BeamSdkEnvs.NumOfParallelJobs()) {
+                       writer.WriteHeader(http.StatusOK)
+               } else {
+                       writer.WriteHeader(http.StatusLocked)
+               }
+       }
+}
+
+// checkNumOfTheParallelJobs checks the number of already working code 
processing.

Review comment:
       Done.

##########
File path: playground/backend/internal/environment/beam.go
##########
@@ -42,17 +42,23 @@ func NewExecutorConfig(compileCmd, runCmd, testCmd string, 
compileArgs, runArgs,
 
 // BeamEnvs contains all environments related of ApacheBeam. These will use to 
run pipelines
 type BeamEnvs struct {
-       ApacheBeamSdk  pb.Sdk
-       ExecutorConfig *ExecutorConfig
-       preparedModDir string
+       ApacheBeamSdk     pb.Sdk
+       ExecutorConfig    *ExecutorConfig
+       preparedModDir    string
+       numOfParallelJobs int
 }
 
 // NewBeamEnvs is a BeamEnvs constructor
-func NewBeamEnvs(apacheBeamSdk pb.Sdk, executorConfig *ExecutorConfig, 
preparedModDir string) *BeamEnvs {
-       return &BeamEnvs{ApacheBeamSdk: apacheBeamSdk, ExecutorConfig: 
executorConfig, preparedModDir: preparedModDir}
+func NewBeamEnvs(apacheBeamSdk pb.Sdk, executorConfig *ExecutorConfig, 
preparedModDir string, numOfParallelJobs int) *BeamEnvs {
+       return &BeamEnvs{ApacheBeamSdk: apacheBeamSdk, ExecutorConfig: 
executorConfig, preparedModDir: preparedModDir, numOfParallelJobs: 
numOfParallelJobs}
 }
 
 // PreparedModDir returns the path to the directory where prepared go.mod and 
go.sum are located
 func (b *BeamEnvs) PreparedModDir() string {
        return b.preparedModDir
 }
+
+// NumOfParallelJobs returns the max number of the possible code processing 
for the SDK on that instance at the same time

Review comment:
       Done.




-- 
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]


Reply via email to